Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2023-07-27 07:37:57
Exec Total Coverage
Lines: 8315 12126 68.6%
Functions: 93 126 73.8%
Branches: 5442 10293 52.9%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // qst.cc
6 //
7 // Code for loading '.qst' files in ZC and ZQuest.
8 //
9 //--------------------------------------------------------
10
11 #include "allegro/file.h"
12 #include "base/util.h"
13 #include "base/zapp.h"
14 #include "base/qrs.h"
15 #include "base/cpool.h"
16 #include "base/packfile.h"
17
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 #include "base/dmap.h"
18 #include "base/combo.h"
19 #include "base/msgstr.h"
20 #include <filesystem>
21 #include <stdio.h>
22 #include <string.h>
23 #include <string>
24 #include <map>
25 #include <vector>
26 #include <assert.h>
27 #include <fmt/format.h>
28
29
30 #include "metadata/sigs/devsig.h.sig"
31 #include "metadata/sigs/compilersig.h.sig"
32 #include "metadata/versionsig.h"
33 #include "base/zc_alleg.h"
34 #include "base/zdefs.h"
35 #include "base/colors.h"
36 #include "tiles.h"
37 #include "base/zsys.h"
38 #include "qst.h"
39 #include "defdata.h"
40 #include "subscr.h"
41 #include "font.h"
42 #include "zc/replay.h"
43 #include "zc/zc_custom.h"
44 #include "sfx.h"
45 #include "md5.h"
46 #include "zinfo.h"
47 #include "zc/ffscript.h"
48 #include "particles.h"
49 #include "dialog/alert.h"
50 #include "base/misctypes.h"
51
52 #ifdef __EMSCRIPTEN__
53 #include "base/emscripten_utils.h"
54 #endif
55
56 //FFScript FFCore;
57 extern FFScript FFCore;
58 extern ZModule zcm;
59 extern zcmodule moduledata;
60 extern uint8_t __isZQuest;
61 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
62 extern particle_list particles;
63 extern void setZScriptVersion(int32_t s_version);
64 //FFSCript FFEngine;
65
66 int32_t temp_ffscript_version = 0;
67 static bool read_ext_zinfo = false, read_zinfo = false;
68 static bool loadquest_report = false;
69 static char const* loading_qst_name = NULL;
70 static byte loading_qst_num = 0;
71
72 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0};
73 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
74
75 #ifdef _MSC_VER
76 #define strncasecmp _strnicmp
77 #endif
78
79 #ifndef _AL_MALLOC
80 #define _AL_MALLOC(a) _al_malloc(a)
81 #define _AL_FREE(a) _al_free(a)
82 #endif
83
84 using std::string;
85 using std::pair;
86
87 // extern bool debug;
88 extern int32_t hero_animation_speed; //lower is faster animation
89 extern std::vector<mapscr> TheMaps;
90 extern std::vector<word> map_autolayers;
91 extern zcmap *ZCMaps;
92 extern byte *colordata;
93 //extern byte *tilebuf;
94 extern tiledata *newtilebuf;
95 extern byte *trashbuf;
96 extern itemdata *itemsbuf;
97 extern wpndata *wpnsbuf;
98 extern comboclass *combo_class_buf;
99 extern guydata *guysbuf;
100 extern ZCHEATS zcheats;
101 extern zinitdata zinit;
102 extern char palnames[MAXLEVELS][17];
103 extern int32_t memrequested;
104 extern char *byte_conversion(int32_t number, int32_t format);
105 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
106 40 string zScript;
107 40 std::map<int32_t, script_slot_data > ffcmap;
108 40 std::map<int32_t, script_slot_data > globalmap;
109 40 std::map<int32_t, script_slot_data > genericmap;
110 40 std::map<int32_t, script_slot_data > itemmap;
111 40 std::map<int32_t, script_slot_data > npcmap;
112 40 std::map<int32_t, script_slot_data > ewpnmap;
113 40 std::map<int32_t, script_slot_data > lwpnmap;
114 40 std::map<int32_t, script_slot_data > playermap;
115 40 std::map<int32_t, script_slot_data > dmapmap;
116 40 std::map<int32_t, script_slot_data > screenmap;
117 40 std::map<int32_t, script_slot_data > itemspritemap;
118 40 std::map<int32_t, script_slot_data > comboscriptmap;
119 void free_newtilebuf();
120 bool combosread=false;
121 bool mapsread=false;
122 bool fixffcs=false;
123 bool fixpolsvoice=false;
124
125
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
126
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
127
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
128
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
129
130 char qstdat_string[2048] = { 0 };
131
132 static zinfo* load_tmp_zi = NULL;
133
134 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
135 const byte clavio[9]={97,109,111,110,103,117,115,0};
136
137 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
138 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
139
140 const char *qst_error[] =
141 {
142 "OK","File not found","Invalid quest file",
143 "Version not supported","Obsolete version",
144 "Missing new data" , /* but let it pass in ZQuest */
145 "Internal error occurred", "Invalid password",
146 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
147 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
148 };
149
150 //for legacy quests -DD
151 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
152 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
153 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
154 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
155 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
156 };
157
158 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
159
160
161 void delete_combo_aliases()
162 {
163 for(int32_t j(0); j<256; j++)
164 {
165 if(combo_aliases[j].combos != NULL)
166 {
167 delete[] combo_aliases[j].combos;
168 combo_aliases[j].combos=NULL;
169 }
170
171 if(combo_aliases[j].csets != NULL)
172 {
173 delete[] combo_aliases[j].csets;
174 combo_aliases[j].csets=NULL;
175 }
176 }
177
178 }
179
180 char *byte_conversion(int32_t number, int32_t format)
181 {
182 static char num_str[40];
183
184 if(format==-1) //auto
185 {
186 format=1; //bytes
187
188 if(number>1024)
189 {
190 format=2; //kilobytes
191 }
192
193 if(number>1024*1024)
194 {
195 format=3; //megabytes
196 }
197
198 if(number>1024*1024*1024)
199 {
200 format=4; //gigabytes (dude, what are you doing?)
201 }
202 }
203
204 switch(format)
205 {
206 case 1: //bytes
207 sprintf(num_str,"%db",number);
208 break;
209
210 case 2: //kilobytes
211 sprintf(num_str,"%.2fk",float(number)/1024);
212 break;
213
214 case 3: //megabytes
215 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
216 break;
217
218 case 4: //gigabytes
219 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
220 break;
221
222 default:
223 abort();
224 break;
225 }
226
227 return num_str;
228 }
229
230 560 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
231 {
232 static char num_str1[40];
233 static char num_str2[40];
234 static char num_str[80];
235
236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 560 times.
560 if(format1==-1) //auto
237 {
238 560 format1=1; //bytes
239
240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 560 times.
560 if(number1>1024)
241 {
242 560 format1=2; //kilobytes
243 560 }
244
245
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 160 times.
560 if(number1>1024*1024)
246 {
247 160 format1=3; //megabytes
248 160 }
249
250
1/2
✓ Branch 0 taken 560 times.
✗ Branch 1 not taken.
560 if(number1>1024*1024*1024)
251 {
252 format1=4; //gigabytes (dude, what are you doing?)
253 }
254 560 }
255
256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 560 times.
560 if(format2==-1) //auto
257 {
258 560 format2=1; //bytes
259
260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 560 times.
560 if(number2>1024)
261 {
262 560 format2=2; //kilobytes
263 560 }
264
265
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 520 times.
560 if(number2>1024*1024)
266 {
267 520 format2=3; //megabytes
268 520 }
269
270
1/2
✓ Branch 0 taken 560 times.
✗ Branch 1 not taken.
560 if(number2>1024*1024*1024)
271 {
272 format2=4; //gigabytes (dude, what are you doing?)
273 }
274 560 }
275
276
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 400 times.
✓ Branch 3 taken 160 times.
✗ Branch 4 not taken.
560 switch(format1)
277 {
278 case 1: //bytes
279 sprintf(num_str1,"%db",number1);
280 break;
281
282 case 2: //kilobytes
283 400 sprintf(num_str1,"%.2fk",float(number1)/1024);
284 400 break;
285
286 case 3: //megabytes
287 160 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
288 160 break;
289
290 case 4: //gigabytes
291 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
292 break;
293
294 default:
295 abort();
296 break;
297 }
298
299
2/5
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 520 times.
✗ Branch 4 not taken.
560 switch(format2)
300 {
301 case 1: //bytes
302 sprintf(num_str2,"%db",number2);
303 break;
304
305 case 2: //kilobytes
306 40 sprintf(num_str2,"%.2fk",float(number2)/1024);
307 40 break;
308
309 case 3: //megabytes
310 520 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
311 520 break;
312
313 case 4: //gigabytes
314 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
315 break;
316
317 default:
318 abort();
319 break;
320 }
321
322 560 sprintf(num_str, "%s/%s", num_str1, num_str2);
323 560 return num_str;
324 }
325
326 char *ordinal(int32_t num)
327 {
328 static const char *ending[4] = {"st","nd","rd","th"};
329 static char ord_str[8];
330
331 char *end;
332 int32_t t=(num%100)/10;
333 int32_t n=num%10;
334
335 if(n>=1 && n<4 && t!=1)
336 end = (char *)ending[n-1];
337 else
338 end = (char *)ending[3];
339
340 sprintf(ord_str,"%d%s",num%10000,end);
341 return ord_str;
342 }
343
344 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
345 {
346 int32_t ret;
347 *version=0;
348 *build=0;
349 byte temp_map_count=map_count;
350 byte temp_midi_flags[MIDIFLAGS_SIZE];
351 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
352
353 zquestheader tempheader;
354
355 if(!f)
356 {
357 return qe_invalid;
358 }
359
360 ret=readheader(f, &tempheader);
361
362 if(ret)
363 {
364 return ret;
365 }
366
367 map_count=temp_map_count;
368 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
369 *version=tempheader.zelda_version;
370 *build=tempheader.build;
371 return 0;
372 }
373
374
375 bool find_section(PACKFILE *f, int32_t section_id_requested)
376 {
377
378 if(!f)
379 {
380 return false;
381 }
382
383 int32_t section_id_read;
384 bool catchup=false;
385 word dummy;
386 byte tempbyte;
387 char tempbuf[65536];
388
389
390 switch(section_id_requested)
391 {
392 case ID_RULES:
393 case ID_STRINGS:
394 case ID_MISC:
395 case ID_TILES:
396 case ID_COMBOS:
397 case ID_CSETS:
398 case ID_MAPS:
399 case ID_DMAPS:
400 case ID_DOORS:
401 case ID_ITEMS:
402 case ID_WEAPONS:
403 case ID_COLORS:
404 case ID_ICONS:
405 case ID_INITDATA:
406 case ID_GUYS:
407 case ID_MIDIS:
408 case ID_CHEATS:
409 break;
410
411 default:
412 al_trace("Bad section requested!\n");
413 return false;
414 break;
415 }
416
417 dword section_size;
418
419 //section id
420 if(!p_mgetl(&section_id_read,f))
421 {
422 return false;
423 }
424
425 while(!pack_feof(f))
426 {
427 switch(section_id_read)
428 {
429 case ID_RULES:
430 case ID_STRINGS:
431 case ID_MISC:
432 case ID_TILES:
433 case ID_COMBOS:
434 case ID_CSETS:
435 case ID_MAPS:
436 case ID_DMAPS:
437 case ID_DOORS:
438 case ID_ITEMS:
439 case ID_WEAPONS:
440 case ID_COLORS:
441 case ID_ICONS:
442 case ID_INITDATA:
443 case ID_GUYS:
444 case ID_MIDIS:
445 case ID_CHEATS:
446 catchup=false;
447 break;
448
449 default:
450 break;
451 }
452
453
454 while(catchup)
455 {
456 //section id
457 section_id_read=(section_id_read<<8);
458
459 if(!p_getc(&tempbyte,f))
460 {
461 return false;
462 }
463
464 section_id_read+=tempbyte;
465 }
466
467 if(section_id_read==section_id_requested)
468 {
469 return true;
470 }
471 else
472 {
473 //section version info
474 if(!p_igetw(&dummy,f))
475 {
476 return false;
477 }
478
479 if(!p_igetw(&dummy,f))
480 {
481 return false;
482 }
483
484 //section size
485 if(!p_igetl(&section_size,f))
486 {
487 return false;
488 }
489
490 //pack_fseek(f, section_size);
491 while(section_size>65535)
492 {
493 pfread(tempbuf,65535,f);
494 tempbuf[65535]=0;
495 section_size-=65535;
496 }
497
498 if(section_size>0)
499 {
500 pfread(tempbuf,section_size,f);
501 tempbuf[section_size]=0;
502 }
503 }
504
505 //section id
506 if(!p_mgetl(&section_id_read,f))
507 {
508 return false;
509 }
510 }
511
512 return false;
513 }
514
515
516
517
518
519 bool valid_zqt(PACKFILE *f)
520 {
521
522 //word tiles_used;
523 //word combos_used;
524 //open the file
525 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
526 if(!f)
527 return false;
528
529 //for now, everything else is valid
530 return true;
531
532 /*int16_t version;
533 byte build;
534
535 //read the version and make sure it worked
536 if(!p_igetw(&version,f))
537 {
538 goto error;
539 }
540
541 //read the build and make sure it worked
542 if(!p_getc(&build,f))
543 goto error;
544
545 //read the tile info and make sure it worked
546 if(!p_igetw(&tiles_used,f))
547 {
548 goto error;
549 }
550
551 for (int32_t i=0; i<tiles_used; i++)
552 {
553 if(!pfread(trashbuf,tilesize(tf4Bit),f))
554 {
555 goto error;
556 }
557 }
558
559 //read the combo info and make sure it worked
560 if(!p_igetw(&combos_used,f))
561 {
562 goto error;
563 }
564 for (int32_t i=0; i<combos_used; i++)
565 {
566 if(!pfread(trashbuf,sizeof(newcombo),f))
567 {
568 goto error;
569 }
570 }
571
572 //read the palette info and make sure it worked
573 for (int32_t i=0; i<48; i++)
574 {
575 if(!pfread(trashbuf,newpdTOTAL,f))
576 {
577 goto error;
578 }
579 }
580 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
581 {
582 goto error;
583 }
584 for (int32_t i=0; i<MAXLEVELS; i++)
585 {
586 if(!pfread(trashbuf,PALNAMESIZE,f))
587 {
588 goto error;
589 }
590 }
591
592 //read the sprite info and make sure it worked
593 for (int32_t i=0; i<MAXITEMS; i++)
594 {
595 if(!pfread(trashbuf,sizeof(itemdata),f))
596 {
597 goto error;
598 }
599 }
600
601 for (int32_t i=0; i<MAXWPNS; i++)
602 {
603 if(!pfread(trashbuf,sizeof(wpndata),f))
604 {
605 goto error;
606 }
607 }
608
609 //read the triforce pieces info and make sure it worked
610 for (int32_t i=0; i<8; ++i)
611 {
612 if(!p_getc(&trashbuf,f))
613 {
614 goto error;
615 }
616 }
617
618
619
620 //read the game icons info and make sure it worked
621 for (int32_t i=0; i<4; ++i)
622 {
623 if(!p_igetw(&trashbuf,f))
624 {
625 goto error;
626 }
627 }
628
629 //read the misc colors info and map styles info and make sure it worked
630 if(!pfread(trashbuf,sizeof(zcolors),f))
631 {
632 goto error;
633 }
634
635 //read the template screens and make sure it worked
636 byte num_maps;
637 if(!p_getc(&num_maps,f))
638 {
639 goto error;
640 }
641 for (int32_t i=0; i<TEMPLATES; i++)
642 {
643 if(!pfread(trashbuf,sizeof(mapscr),f))
644 {
645 goto error;
646 }
647 }
648 if (num_maps>1) //dungeon templates
649 {
650 for (int32_t i=0; i<TEMPLATES; i++)
651 {
652 if(!pfread(trashbuf,sizeof(mapscr),f))
653 {
654 goto error;
655 }
656 }
657 }
658
659 //yay! it worked! close the file and say everything was ok.
660 pack_fclose(f);
661 return true;
662
663 error:
664 pack_fclose(f);
665 return false;*/
666 }
667
668 bool valid_zqt(const char *filename)
669 {
670 PACKFILE *f=NULL;
671 bool isvalid;
672 int32_t error;
673 f=open_quest_file(&error, filename, false);
674
675 if(!f)
676 {
677 // setPackfilePassword(NULL);
678 return false;
679 }
680
681 isvalid=valid_zqt(f);
682
683 clear_quest_tmpfile();
684 pack_fclose(f);
685
686 // setPackfilePassword(NULL);
687 return isvalid;
688 }
689
690 40 static std::string tmp_file_name;
691 246 void clear_quest_tmpfile()
692 {
693
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 if(tmp_file_name.size())
694 {
695 if(exists(tmp_file_name.c_str()))
696 delete_file(tmp_file_name.c_str());
697 tmp_file_name.clear();
698 }
699 246 }
700 /*
701 .qst file history
702
703 .qst files have always been compressed using allegro's packfiles.
704
705 At some point, an encoding layer was added. The two layers look like this:
706
707 1) The top layer is from us. See decode_file_007.
708 [0-24] Preamble "Zelda Classic Quest File"
709 [25-28] Initial decoding seed value.
710 [29-X] Allegro-encoded payload (AKA "packed" file)
711 [last 4] Checksum
712
713 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
714 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
715 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
716 The oldest quests skip the password part.
717
718 Simply, the job of this function is to peel away the top layer.
719
720 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
721 in opening and saving files. There is no version field, so they decryption key is
722 found via trial-by-error (very slow!)
723
724 There are other file types of interest:
725 - .zqt: quest template files, skips top-layer encryption pass
726 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
727 - .qu?: same as above. automated backup files
728 - .qb?: same as above. automated backup files
729 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
730
731 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
732 files are now "slh!.AG ZC Enhanced Quest File".
733 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
734 */
735 123 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
736 {
737
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if (show_progress)
738 {
739 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
740 }
741
742 #ifdef __EMSCRIPTEN__
743 if (em_is_lazy_file(filename))
744 {
745 em_fetch_file(filename);
746 }
747 #endif
748 123 clear_quest_tmpfile();
749 // Note: although this is primarily for loading .qst files, it can also handle all of the
750 // file types mentioned in the comment above. No need to be told if the file being loaded
751 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
752 123 bool top_layer_compressed = false;
753 123 bool compressed = false;
754 123 bool encrypted = false;
755
756 // Input files may or may not include a top layer, which may or may not be compressed.
757 // Additionally, the bottom layer may or may not be compressed, and may or may not be encoded
758 // with an allegro packfile password (longtan).
759 // We peek into this file to read the header - we'll either see the top layer's header (ENC_STR)
760 // or the bottom layer's header (QH_IDSTR or QH_NEWIDSTR).
761 // Newly saved .qst files enjoy a fast path here, where there is no top layer at all.
762
763 123 bool id_came_from_compressed_file = false;
764 123 const char* packfile_password = "";
765 char id[32];
766 123 id[0] = id[31] = '\0';
767 123 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, "");
768
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 3 times.
123 if (!pf)
769 3 pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password = datapwd);
770
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 3 times.
123 if (pf)
771 {
772 120 id_came_from_compressed_file = true;
773
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if (!pack_fread(id, sizeof(id)-1, pf))
774 {
775 pack_fclose(pf);
776 Z_message("Unable to read header string\n");
777 return nullptr;
778 }
779 120 pack_fclose(pf);
780 120 }
781 else
782 {
783 3 FILE* f = fopen(filename, "rb");
784
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (!f)
785 {
786 *open_error=qe_notfound;
787 return nullptr;
788 }
789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!fread(id, sizeof(char), sizeof(id)-1, f))
790 {
791 fclose(f);
792 Z_message("Unable to read header string\n");
793 return nullptr;
794 }
795 3 fclose(f);
796 }
797
798
4/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 3 times.
123 if (strstr(id, QH_NEWIDSTR) || strstr(id, QH_IDSTR))
799 {
800 // The given file is already just the bottom layer - nothing more to do.
801 // There's no way to rewind a packfile, so just open it again.
802
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if (id_came_from_compressed_file)
803 {
804 120 return pack_fopen_password(filename, F_READ_PACKED, packfile_password);
805 }
806 else
807 {
808 return pack_fopen_password(filename, F_READ, "");
809 }
810 }
811
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 else if (strstr(id, ENC_STR))
812 {
813 3 top_layer_compressed = id_came_from_compressed_file;
814 3 compressed = true;
815 3 encrypted = true;
816 3 }
817 else if (id_came_from_compressed_file && strstr(id, "slh!\xff"))
818 {
819 // We must be reading the compressed contents of an allegro dataobject file. ex: `classic_qst.dat#NESQST_NEW_QST`.
820 // Let's extract the content and re-open as a separate file, so allegro will uncompress correctly.
821
822 char tmpfilename[L_tmpnam];
823 std::tmpnam(tmpfilename);
824 FILE* tf = fopen(tmpfilename, "wb");
825 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password);
826
827 int c;
828 while ((c = pack_getc(pf)) != EOF)
829 {
830 fputc(c, tf);
831 }
832 fclose(tf);
833 pack_fclose(pf);
834
835 tmp_file_name = tmpfilename; //store so it can be cleaned up later
836
837 // not good: temp file storage leak. Callers don't know to delete temp files anymore.
838 // We should put qsu in the dat file, or use a separate .qst file for new qst.
839 return pack_fopen_password(tmpfilename, F_READ_PACKED, "");
840 }
841 else
842 {
843 // Unexpected, this is going to fail some header check later.
844 }
845
846 // Everything below here is legacy code - recently saved quest files will have
847 // returned by now.
848
849 char tmpfilename[L_tmpnam];
850 3 temp_name(tmpfilename);
851 char percent_done[30];
852 3 int32_t current_method=0;
853
854 PACKFILE *f;
855 3 const char *passwd= encrypted ? datapwd : "";
856
857 // oldquest flag is set when an unencrypted qst file is suspected.
858 3 bool oldquest = false;
859 int32_t ret;
860
861
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(strcmp(filename, "default.qst")!=0)
862 {
863 3 box_out(filename);
864 3 }
865 else
866 {
867 box_out("new quest"); // Or whatever
868 }
869 3 box_out("...");
870 3 box_eol();
871 3 box_eol();
872
873
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(encrypted)
874 {
875 3 box_out("Decrypting...");
876 3 box_save_x();
877 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
878
879
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret)
880 {
881 switch(ret)
882 {
883 case 1:
884 box_out("error.");
885 box_eol();
886 box_end(true);
887 *open_error=qe_notfound;
888 return NULL;
889
890 case 2:
891 box_out("error.");
892 box_eol();
893 box_end(true);
894 *open_error=qe_internal;
895 return NULL;
896 // be sure not to delete tmpfilename now...
897 }
898
899 if(ret==5) //old encryption?
900 {
901 current_method++;
902 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
903 box_out(percent_done);
904 box_load_x();
905 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
906 }
907
908 if(ret==5) //old encryption?
909 {
910 current_method++;
911 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
912 box_out(percent_done);
913 box_load_x();
914 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
915 }
916
917 if(ret==5) //old encryption?
918 {
919 current_method++;
920 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
921 box_out(percent_done);
922 box_load_x();
923 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
924 }
925
926 if(ret==5) //old encryption?
927 {
928 current_method++;
929 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
930 box_out(percent_done);
931 box_load_x();
932 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
933 }
934
935 if(ret)
936 {
937 oldquest = true;
938 passwd="";
939 }
940 }
941
942 3 box_out("okay.");
943 3 box_eol();
944 3 }
945 else
946 {
947 oldquest = true;
948 }
949
950 3 box_out("Opening...");
951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
952
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!f)
953 {
954 if((compressed==1)&&(errno==EDOM))
955 {
956 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
957 }
958
959 if(!f)
960 {
961 if(!oldquest)
962 {
963 delete_file(tmpfilename);
964 }
965 box_out("error.");
966 box_eol();
967 box_end(true);
968 *open_error=qe_invalid;
969 return NULL;
970 }
971 }
972
973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!oldquest)
974 {
975 3 delete_file(tmpfilename);
976 3 }
977
978 3 box_out("okay.");
979 3 box_eol();
980
981 3 return f;
982 123 }
983
984 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
985 {
986 char *filename;
987 PACKFILE *f=NULL;
988 int32_t open_error=0;
989
990 strcpy(qstdat_string, "modules/classic/default.qst");
991 if(Header->templatepath[0]==0)
992 {
993 filename=(char *)malloc(2048);
994 strcpy(filename, qstdat_string);
995 }
996 else
997 {
998 // TODO: should be safe to remove this, no one seems to use custom quest templates.
999 filename=Header->templatepath;
1000 }
1001
1002 f=open_quest_file(&open_error, filename, false);
1003
1004 if(Header->templatepath[0]==0)
1005 {
1006 free(filename);
1007 }
1008
1009 if(!f)
1010 {
1011 return NULL;
1012 }
1013
1014 if(validate)
1015 {
1016 if(!valid_zqt(f))
1017 {
1018 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
1019 pack_fclose(f);
1020 clear_quest_tmpfile();
1021 return NULL;
1022 }
1023 }
1024
1025 return f;
1026 }
1027
1028 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
1029 {
1030 // We absolutely do not support loading from a template file to initialize data outside the editor.
1031 // TODO: move this code into zq/
1032 if (get_app_id() != App::zquest) return false;
1033
1034 combosread=false;
1035 mapsread=false;
1036 fixffcs=false;
1037
1038 switch(section_id)
1039 {
1040 case ID_RULES:
1041 case ID_STRINGS:
1042 case ID_MISC:
1043 case ID_TILES:
1044 case ID_COMBOS:
1045 case ID_CSETS:
1046 case ID_MAPS:
1047 case ID_DMAPS:
1048 case ID_DOORS:
1049 case ID_ITEMS:
1050 case ID_WEAPONS:
1051 case ID_COLORS:
1052 case ID_ICONS:
1053 case ID_INITDATA:
1054 case ID_GUYS:
1055 case ID_MIDIS:
1056 case ID_CHEATS:
1057 case ID_ITEMDROPSETS:
1058 case ID_FAVORITES:
1059 break;
1060
1061 default:
1062 return false;
1063 break;
1064 }
1065
1066 int32_t ret;
1067 word version, build;
1068 PACKFILE *f=NULL;
1069
1070 char deletefilename[1024];
1071 deletefilename[0]=0;
1072
1073 //why is this here?
1074 /*
1075 if(colordata==NULL)
1076 return false;
1077 */
1078
1079 //setPackfilePassword(datapwd);
1080 f=open_quest_template(Header, deletefilename, validate);
1081
1082 if(!f) //no file, nothing to delete
1083 {
1084 // setPackfilePassword(NULL);
1085 return false;
1086 }
1087
1088 ret=get_version_and_build(f, &version, &build);
1089
1090 if(ret||(version==0))
1091 {
1092 pack_fclose(f);
1093 clear_quest_tmpfile();
1094
1095 if(deletefilename[0])
1096 {
1097 delete_file(deletefilename);
1098 }
1099
1100 // setPackfilePassword(NULL);
1101 return false;
1102 }
1103
1104 if(!find_section(f, section_id))
1105 {
1106 al_trace("Can't find section!\n");
1107 pack_fclose(f);
1108 clear_quest_tmpfile();
1109
1110 if(deletefilename[0])
1111 {
1112 delete_file(deletefilename);
1113 }
1114
1115 //setPackfilePassword(NULL);
1116 return false;
1117 }
1118
1119 switch(section_id)
1120 {
1121 case ID_RULES:
1122 //rules
1123 ret=readrules(f, Header);
1124 break;
1125
1126 case ID_STRINGS:
1127 //strings
1128 ret=readstrings(f, Header);
1129 break;
1130
1131 case ID_MISC:
1132 //misc data
1133 ret=readmisc(f, Header, Misc);
1134 break;
1135
1136 case ID_TILES:
1137 //tiles
1138 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1139 break;
1140
1141 case ID_COMBOS:
1142 //combos
1143 clear_combos();
1144 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1145 combosread=true;
1146 break;
1147
1148 case ID_COMBOALIASES:
1149 //combos
1150 ret=readcomboaliases(f, Header, version, build);
1151 break;
1152
1153 case ID_CSETS:
1154 //color data
1155 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1156 break;
1157
1158 case ID_MAPS:
1159 //maps
1160 ret=readmaps(f, Header);
1161 mapsread=true;
1162 break;
1163
1164 case ID_DMAPS:
1165 //dmaps
1166 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1167 break;
1168
1169 case ID_DOORS:
1170 //door combo sets
1171 ret=readdoorcombosets(f, Header);
1172 break;
1173
1174 case ID_ITEMS:
1175 //items
1176 ret=readitems(f, version, build);
1177 break;
1178
1179 case ID_WEAPONS:
1180 //weapons
1181 ret=readweapons(f, Header);
1182 break;
1183
1184 case ID_COLORS:
1185 //misc. colors
1186 ret=readmisccolors(f, Header, Misc);
1187 break;
1188
1189 case ID_ICONS:
1190 //game icons
1191 ret=readgameicons(f, Header, Misc);
1192 break;
1193
1194 case ID_INITDATA:
1195 //initialization data
1196 ret=readinitdata(f, Header);
1197 break;
1198
1199 case ID_GUYS:
1200 //guys
1201 ret=readguys(f, Header);
1202 break;
1203
1204 case ID_MIDIS:
1205 //midis
1206 ret=readtunes(f, Header, tunes);
1207 break;
1208
1209 case ID_CHEATS:
1210 //cheat codes
1211 ret=readcheatcodes(f, Header);
1212 break;
1213
1214 case ID_ITEMDROPSETS:
1215 //item drop sets
1216 // Why is this one commented out?
1217 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1218 break;
1219
1220 case ID_FAVORITES:
1221 // favorite combos and aliases
1222 ret=readfavorites(f, version, build);
1223 break;
1224
1225 default:
1226 ret=-1;
1227 break;
1228 }
1229
1230 pack_fclose(f);
1231 clear_quest_tmpfile();
1232
1233 if(deletefilename[0])
1234 {
1235 delete_file(deletefilename);
1236 }
1237
1238 //setPackfilePassword(NULL);
1239 if(!ret)
1240 {
1241 return true;
1242 }
1243
1244 return false;
1245 }
1246
1247 bool init_tiles(bool validate, zquestheader *Header)
1248 {
1249 return init_section(Header, ID_TILES, NULL, NULL, validate);
1250 }
1251
1252 bool init_combos(bool validate, zquestheader *Header)
1253 {
1254 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1255 }
1256
1257 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1258 {
1259 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1260 }
1261
1262 123 void init_spritelists()
1263 {
1264
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 30 times.
123 if(FFCore.quest_format[vZelda] < 0x255)
1265 {
1266 93 guys.setMax(255);
1267 93 items.setMax(255);
1268 93 Ewpns.setMax(255);
1269 93 Lwpns.setMax(255);
1270 93 Sitems.setMax(255);
1271 93 chainlinks.setMax(255);
1272 93 decorations.setMax(255);
1273 93 particles.setMax(255);
1274 93 }
1275 else
1276 {
1277 30 guys.setMax(255);
1278 30 items.setMax(255);
1279 30 Ewpns.setMax(255);
1280 30 Lwpns.setMax(255);
1281 30 Sitems.setMax(255);
1282 30 chainlinks.setMax(255);
1283 30 decorations.setMax(255);
1284 30 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1285 }
1286 123 }
1287
1288 40 bool reset_items(bool validate, zquestheader *Header)
1289 {
1290 40 bool ret = true;
1291
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if (get_app_id() == App::zquest)
1292 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1293
1294
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 10240 times.
10280 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1295
1296 40 return ret;
1297 }
1298
1299 bool reset_guys()
1300 {
1301 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1302 init_guys(V_GUYS);
1303 return true;
1304 }
1305
1306 bool reset_wpns(bool validate, zquestheader *Header)
1307 {
1308 bool ret = true;
1309 if (get_app_id() == App::zquest)
1310 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1311
1312 for(int32_t i=0; i<MAXWPNS; i++)
1313 reset_weaponname(i);
1314
1315 return ret;
1316 }
1317
1318 bool reset_mapstyles(bool validate, miscQdata *Misc)
1319 {
1320 Misc->colors.blueframe_tile = 20044;
1321 Misc->colors.blueframe_cset = 0;
1322 Misc->colors.triforce_tile = 23461;
1323 Misc->colors.triforce_cset = 1;
1324 Misc->colors.triframe_tile = 18752;
1325 Misc->colors.triframe_cset = 1;
1326 Misc->colors.overworld_map_tile = 16990;
1327 Misc->colors.overworld_map_cset = 2;
1328 Misc->colors.HCpieces_tile = 21160;
1329 Misc->colors.HCpieces_cset = 8;
1330 Misc->colors.dungeon_map_tile = 19651;
1331 Misc->colors.dungeon_map_cset = 8;
1332 return true;
1333 }
1334
1335 40 int32_t get_qst_buffers()
1336 {
1337 40 memrequested+=(sizeof(mapscr)*MAPSCRS);
1338 40 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1339 40 TheMaps.resize(MAPSCRS);
1340 40 map_autolayers.resize(6);
1341
1342
2/2
✓ Branch 0 taken 5440 times.
✓ Branch 1 taken 40 times.
5480 for(int32_t i(0); i<MAPSCRS; i++)
1343 5440 TheMaps[i].zero_memory();
1344
1345 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1346 40 Z_message("OK\n"); // Allocating map buffer...
1347
1348 40 memrequested+=(sizeof(zcmap)*MAXMAPS2);
1349 40 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(zcmap)*MAXMAPS2,memrequested,-1,-1));
1350
1351
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if((ZCMaps=(zcmap*)malloc(sizeof(zcmap)*MAXMAPS2))==NULL)
1352 return 0;
1353
1354 40 Z_message("OK\n");
1355
1356 // Allocating space for all 65535 strings uses up 10.62MB...
1357 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1358 // (Shoelace's "Hero of Dreams" uses 1415.)
1359 // So let's be a bit generous and allow 4096 initially.
1360 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1361 // I tested it and it worked without flaw on 6/6/11. - L.
1362 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1363 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1364 // See https://discord.com/channels/876899628556091432/992984989073416242
1365 40 msg_strings_size = 8192;
1366 40 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1367 40 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1368
1369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 MsgStrings = new MsgStr[msg_strings_size];
1370
1371 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1372
2/2
✓ Branch 0 taken 327680 times.
✓ Branch 1 taken 40 times.
327720 for(auto q = 0; q < msg_strings_size; ++q)
1373 {
1374 327680 MsgStrings[q].clear();
1375 327680 }
1376 40 Z_message("OK\n"); // Allocating string buffer...
1377
1378 40 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1379 40 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1380
1381
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1382 return 0;
1383
1384 40 Z_message("OK\n"); // Allocating door combo buffer...
1385
1386 40 memrequested+=(sizeof(dmap)*MAXDMAPS);
1387 40 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1388
1389
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if((DMaps=(dmap*)malloc(sizeof(dmap)*MAXDMAPS))==NULL)
1390 return 0;
1391
1392 40 memset(DMaps, 0, sizeof(dmap)*MAXDMAPS);
1393 40 Z_message("OK\n"); // Allocating dmap buffer...
1394
1395 40 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1396 40 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1397
1398 40 combobuf.clear();
1399 40 combobuf.resize(MAXCOMBOS);
1400 40 Z_message("OK\n"); // Allocating combo buffer...
1401
1402 40 memrequested+=(psTOTAL255);
1403 40 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1404
1405
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1406 return 0;
1407
1408 40 Z_message("OK\n"); // Allocating color data buffer...
1409
1410 40 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1411 40 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1412
1413 40 free_newtilebuf();
1414
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1415 return 0;
1416
1417 40 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1418 //Z_message("Performed memset on tiles\n");
1419 40 clear_tiles(newtilebuf);
1420 //Z_message("Performed clear_tiles()\n");
1421 40 Z_message("OK\n"); // Allocating tile buffer...
1422
1423
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(is_zquest())
1424 {
1425 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1426 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1427
1428 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1429 return 0;
1430
1431 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1432 clear_tiles(grabtilebuf);
1433 Z_message("OK\n"); // Allocating tile grab buffer...
1434 }
1435
1436 40 memrequested+=(100000);
1437 40 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1438
1439
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if((trashbuf=(byte*)malloc(100000))==NULL)
1440 return 0;
1441
1442 40 Z_message("OK\n"); // Allocating trash buffer...
1443
1444 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1445 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1446 // fixed by ensuring there's actually itemdata there.
1447 // If you change this, be sure to update del_qst_buffers, too.
1448
1449 40 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1450 40 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1451
1452
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1453 return 0;
1454
1455 40 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1456 40 itemsbuf++;
1457 40 Z_message("OK\n"); // Allocating item buffer...
1458
1459 40 memrequested+=(sizeof(wpndata)*MAXWPNS);
1460 40 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1461
1462
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1463 return 0;
1464
1465 40 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1466 40 Z_message("OK\n"); // Allocating weapon buffer...
1467
1468 40 memrequested+=(sizeof(guydata)*MAXGUYS);
1469 40 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1470
1471
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1472 return 0;
1473
1474 40 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1475 40 Z_message("OK\n"); // Allocating guy buffer...
1476
1477 40 memrequested+=(sizeof(comboclass)*cMAX);
1478 40 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1479
1480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1481 return 0;
1482
1483 40 Z_message("OK\n"); // Allocating combo class buffer...
1484
1485 40 return 1;
1486 40 }
1487
1488
1489 40 void free_newtilebuf()
1490 {
1491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(newtilebuf)
1492 {
1493 for(int32_t i=0; i<NEWMAXTILES; i++)
1494 if(newtilebuf[i].data)
1495 free(newtilebuf[i].data);
1496
1497 free(newtilebuf);
1498 newtilebuf = 0;
1499 }
1500 40 }
1501
1502 void free_grabtilebuf()
1503 {
1504 if(is_zquest())
1505 {
1506 if(grabtilebuf)
1507 {
1508 for(int32_t i=0; i<NEWMAXTILES; i++)
1509 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1510
1511 free(grabtilebuf);
1512 grabtilebuf = 0;
1513 }
1514 }
1515 }
1516
1517 void del_qst_buffers()
1518 {
1519 al_trace("Cleaning maps. \n");
1520
1521 if(ZCMaps) free(ZCMaps);
1522
1523 if(MsgStrings) delete[] MsgStrings;
1524
1525 if(DoorComboSets) free(DoorComboSets);
1526
1527 if(DMaps) free(DMaps);
1528
1529 combobuf.clear();
1530
1531 if(colordata) free(colordata);
1532
1533 al_trace("Cleaning tile buffers. \n");
1534 free_newtilebuf();
1535 free_grabtilebuf();
1536
1537 al_trace("Cleaning misc. \n");
1538
1539 if(trashbuf) free(trashbuf);
1540
1541 // See get_qst_buffers
1542 if(itemsbuf)
1543 {
1544 itemsbuf--;
1545 free(itemsbuf);
1546 }
1547
1548 if(wpnsbuf) free(wpnsbuf);
1549
1550 if(guysbuf) free(guysbuf);
1551
1552 if(combo_class_buf) free(combo_class_buf);
1553 }
1554
1555 4 bool init_palnames()
1556 {
1557 // if(palnames==NULL)
1558 // return false;
1559
1560
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t x=0; x<MAXLEVELS; x++)
1561 {
1562
4/4
✓ Branch 0 taken 2036 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
2048 switch(x)
1563 {
1564 case 0:
1565 4 sprintf(palnames[x],"Overworld");
1566 4 break;
1567
1568 case 10:
1569 4 sprintf(palnames[x],"Caves");
1570 4 break;
1571
1572 case 11:
1573 4 sprintf(palnames[x],"Passageways");
1574 4 break;
1575
1576 default:
1577 2036 sprintf(palnames[x],"%c",0);
1578 2036 break;
1579 }
1580 2048 }
1581
1582 4 return true;
1583 }
1584
1585 25198 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1586 {
1587 void *p;
1588
1589
1/2
✓ Branch 0 taken 25198 times.
✗ Branch 1 not taken.
25198 p = _AL_MALLOC(MAX(size, alloc_size));
1590
1591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25198 times.
25198 if(!p)
1592 {
1593 return NULL;
1594 }
1595
1596
1/2
✓ Branch 0 taken 25198 times.
✗ Branch 1 not taken.
25198 if(!pfread(p,size,f))
1597 {
1598 _AL_FREE(p);
1599 return NULL;
1600 }
1601
1602
1/2
✓ Branch 0 taken 25198 times.
✗ Branch 1 not taken.
25198 if(pack_ferror(f))
1603 {
1604 _AL_FREE(p);
1605 return NULL;
1606 }
1607
1608 25198 return p;
1609 25198 }
1610
1611 /* read_midi:
1612 * Reads MIDI data from a datafile (this is not the same thing as the
1613 * standard midi file format).
1614 */
1615
1616 2296 static MIDI *read_midi(PACKFILE *f)
1617 {
1618 MIDI *m;
1619 int32_t c;
1620 2296 int16_t divisions=0;
1621 2296 int32_t len=0;
1622
1623 2296 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1624
1625
1/2
✓ Branch 0 taken 2296 times.
✗ Branch 1 not taken.
2296 if(!m)
1626 {
1627 return NULL;
1628 }
1629
1630
2/2
✓ Branch 0 taken 73472 times.
✓ Branch 1 taken 2296 times.
75768 for(c=0; c<MIDI_TRACKS; c++)
1631 {
1632 73472 m->track[c].len = 0;
1633 73472 m->track[c].data = NULL;
1634 73472 }
1635
1636 2296 p_mgetw(&divisions,f);
1637 2296 m->divisions=divisions;
1638
1639
2/2
✓ Branch 0 taken 73472 times.
✓ Branch 1 taken 2296 times.
75768 for(c=0; c<MIDI_TRACKS; c++)
1640 {
1641 73472 p_mgetl(&len,f);
1642 73472 m->track[c].len=len;
1643
1644
2/2
✓ Branch 0 taken 48274 times.
✓ Branch 1 taken 25198 times.
73472 if(m->track[c].len > 0)
1645 {
1646 25198 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1647
1648
1/2
✓ Branch 0 taken 25198 times.
✗ Branch 1 not taken.
25198 if(!m->track[c].data)
1649 {
1650 destroy_midi(m);
1651 return NULL;
1652 }
1653 25198 }
1654 73472 }
1655
1656 LOCK_DATA(m, sizeof(MIDI));
1657
1658
2/2
✓ Branch 0 taken 73472 times.
✓ Branch 1 taken 2296 times.
75768 for(c=0; c<MIDI_TRACKS; c++)
1659 {
1660
2/2
✓ Branch 0 taken 25198 times.
✓ Branch 1 taken 48274 times.
73472 if(m->track[c].data)
1661 {
1662 LOCK_DATA(m->track[c].data, m->track[c].len);
1663 25198 }
1664 73472 }
1665
1666 2296 return m;
1667 2296 }
1668
1669 void clear_combo(int32_t i)
1670 {
1671 combobuf[i].clear();
1672 }
1673
1674 void clear_combos()
1675 {
1676 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1677 clear_combo(tmpcounter);
1678 }
1679
1680 void pack_combos()
1681 {
1682 int32_t di = 0;
1683
1684 for(int32_t si=0; si<1024; si+=2)
1685 combobuf[di++] = combobuf[si];
1686
1687 for(; di<1024; di++)
1688 clear_combo(di);
1689 }
1690
1691 123 void reset_tunes(zctune *tune)
1692 {
1693
2/2
✓ Branch 0 taken 30996 times.
✓ Branch 1 taken 123 times.
31119 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1694 {
1695 30996 tune[i].reset();
1696 30996 }
1697 123 }
1698
1699
1700 /*void reset_midi(zcmidi_ *m)
1701 {
1702 m->title[0]=0;
1703 m->loop=1;
1704 m->volume=144;
1705 m->start=0;
1706 m->loop_start=-1;
1707 m->loop_end=-1;
1708 if(m->midi)
1709 {
1710 destroy_midi(m->midi);
1711 }
1712 m->midi=NULL;
1713 }
1714
1715
1716 void reset_midis(zcmidi_ *m)
1717 {
1718 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1719 {
1720 reset_midi(m+i);
1721 }
1722 }
1723 */
1724
1725 void reset_scr(int32_t scr)
1726 {
1727 /*
1728 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1729 for(unsigned i=0; i<sizeof(mapscr); i++)
1730 *(di++) = 0;
1731 TheMaps[scr].valid=mVERSION;
1732 */
1733
1734 TheMaps[scr].zero_memory();
1735 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1736
1737 for(int32_t i=0; i<6; i++)
1738 {
1739 //these will be uncommented later
1740 //TheMaps[scr].layerxsize[i]=16;
1741 //TheMaps[scr].layerysize[i]=11;
1742 TheMaps[scr].layeropacity[i]=255;
1743 }
1744
1745 TheMaps[scr].valid=mVERSION;
1746
1747 }
1748
1749 /* For reference:
1750
1751 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1752 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1753 */
1754
1755 3582 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1756 {
1757
2/2
✓ Branch 0 taken 16494 times.
✓ Branch 1 taken 1614 times.
18108 for(int32_t i=0; i<9; i++)
1758 {
1759
2/2
✓ Branch 0 taken 89124 times.
✓ Branch 1 taken 14526 times.
103650 for(int32_t j=0; j<6; j++)
1760 {
1761
2/2
✓ Branch 0 taken 29052 times.
✓ Branch 1 taken 60072 times.
89124 if(j<4)
1762 {
1763
2/2
✓ Branch 0 taken 58104 times.
✓ Branch 1 taken 1968 times.
60072 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1764 {
1765 1968 return false;
1766 }
1767
1768
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1769 {
1770 return false;
1771 }
1772
1773
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1774 {
1775 return false;
1776 }
1777
1778
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1779 {
1780 return false;
1781 }
1782 58104 }
1783
1784
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1785 {
1786 return false;
1787 }
1788
1789
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1790 {
1791 return false;
1792 }
1793
1794
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1795 {
1796 return false;
1797 }
1798
1799
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1800 {
1801 return false;
1802 }
1803 87156 }
1804
1805
2/2
✓ Branch 0 taken 11298 times.
✓ Branch 1 taken 3228 times.
14526 if(i<2)
1806 {
1807
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.flags[i]!=b.flags[i])
1808 {
1809 return false;
1810 }
1811
1812
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1813 {
1814 return false;
1815 }
1816
1817
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1818 {
1819 return false;
1820 }
1821
1822
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1823 {
1824 return false;
1825 }
1826
1827
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1828 {
1829 return false;
1830 }
1831 3228 }
1832
1833
2/2
✓ Branch 0 taken 9684 times.
✓ Branch 1 taken 4842 times.
14526 if(i<3)
1834 {
1835
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1836 {
1837 return false;
1838 }
1839
1840
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1841 {
1842 return false;
1843 }
1844
1845
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1846 {
1847 return false;
1848 }
1849
1850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4842 times.
4842 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1851 {
1852 return false;
1853 }
1854 4842 }
1855
1856
1/2
✓ Branch 0 taken 14526 times.
✗ Branch 1 not taken.
14526 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1857 {
1858 return false;
1859 }
1860
1861
1/2
✓ Branch 0 taken 14526 times.
✗ Branch 1 not taken.
14526 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1862 {
1863 return false;
1864 }
1865 14526 }
1866
1867 1614 return true;
1868 3582 }
1869
1870 int32_t doortranslations_u[9][4]=
1871 {
1872 {37,38,53,54},
1873 {37,38,39,40},
1874 {37,38,55,56},
1875 {37,38,39,40},
1876 {37,38,53,54},
1877 {37,38,53,54},
1878 {37,38,53,54},
1879 {7,8,23,24},
1880 {7,8,41,42}
1881 };
1882
1883 int32_t doortranslations_d[9][4]=
1884 {
1885 {117,118,133,134},
1886 {135,136,133,134},
1887 {119,120,133,134},
1888 {135,136,133,134},
1889 {117,118,133,134},
1890 {117,118,133,134},
1891 {117,118,133,134},
1892 {151,152,167,168},
1893 {137,138,167,168},
1894 };
1895
1896 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1897 int32_t doortranslations_l[9][6]=
1898 {
1899 {66,67,82,83,98,99},
1900 {66,68,82,84,98,100},
1901 {66,69,82,85,98,101},
1902 {66,68,82,84,98,100},
1903 {66,67,82,83,98,99},
1904 {66,67,82,83,98,99},
1905 {66,67,82,83,98,99},
1906 {64,65,80,81,96,97},
1907 {64,65,80,114,96,97},
1908 };
1909
1910 int32_t doortranslations_r[9][6]=
1911 {
1912
1913 {76,77,92,93,108,109},
1914 {75,77,91,93,107,109},
1915 {74,77,90,93,106,109},
1916 {75,77,91,93,107,109},
1917 {76,77,92,93,108,109},
1918 {76,77,92,93,108,109},
1919 {76,77,92,93,108,109},
1920 {78,79,94,95,110,111},
1921 {78,79,125,95,110,111},
1922 };
1923
1924 314668 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1925 {
1926 314668 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1927 }
1928
1929 308180 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1930 {
1931 //these are here to bypass compiler warnings about unused arguments
1932 308180 map=map;
1933 308180 scr=scr;
1934 308180 pos=pos;
1935
1936 //what does this function do?
1937 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1938 308180 return 2;
1939 }
1940
1941 7072 int32_t MakeDoors(int32_t map, int32_t scr)
1942 {
1943
2/2
✓ Branch 0 taken 5450 times.
✓ Branch 1 taken 1622 times.
7072 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1944 {
1945 5450 return 0;
1946 }
1947
1948 DoorComboSet tempdcs;
1949 1622 memset(&tempdcs, 0, sizeof(DoorComboSet));
1950
1951 //up
1952
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1953 {
1954
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1955 {
1956 58392 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1957 58392 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1958 58392 }
1959 14598 }
1960
1961 1622 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1962 1622 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1963 1622 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1964 1622 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1965 1622 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1966 1622 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1967
1968 //down
1969
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1970 {
1971
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1972 {
1973 58392 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1974 58392 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1975 58392 }
1976 14598 }
1977
1978 1622 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1979
1980 1622 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1981 1622 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1982 1622 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1983 1622 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1984 1622 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1985
1986 //left
1987 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1988
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1989 {
1990
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1991 {
1992 87588 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1993 87588 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1994 87588 }
1995 14598 }
1996
1997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1998 {
1999 if((j!=2)&&(j!=3))
2000 {
2001 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
2002 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
2003 }
2004 }
2005
2006 1622 tempdcs.bombdoorcombo_l[0]=0;
2007 1622 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
2008 1622 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
2009 1622 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
2010 1622 tempdcs.bombdoorcombo_l[2]=0;
2011 1622 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
2012 1622 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
2013 1622 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
2014
2015 //right
2016
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
2017 {
2018
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
2019 {
2020 87588 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
2021 87588 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
2022 87588 }
2023 14598 }
2024
2025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
2026 {
2027 if((j!=2)&&(j!=3))
2028 {
2029 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
2030 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
2031 }
2032 }
2033
2034 1622 tempdcs.bombdoorcombo_r[0]=0;
2035 1622 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
2036 1622 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
2037 1622 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
2038 1622 tempdcs.bombdoorcombo_r[2]=0;
2039 1622 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
2040 1622 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
2041 1622 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
2042
2043 int32_t k;
2044
2045
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3582 times.
3590 for(k=0; k<door_combo_set_count; k++)
2046 {
2047
2/2
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 1968 times.
3582 if(DoorComboSets[k]==tempdcs)
2048 {
2049 1614 break;
2050 }
2051 1968 }
2052
2053
2/2
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 8 times.
1622 if(k==door_combo_set_count)
2054 {
2055 8 DoorComboSets[k]=tempdcs;
2056 8 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
2057 8 ++door_combo_set_count;
2058 8 }
2059
2060 1622 return k;
2061 /*
2062 doorcombo_u[9][4];
2063 doorcset_u[9][4];
2064 doorcombo_d[9][4];
2065 doorcset_d[9][4];
2066 doorcombo_l[9][6];
2067 doorcset_l[9][6];
2068 doorcombo_r[9][6];
2069 doorcset_r[9][6];
2070 bombdoorcombo_u[2];
2071 bombdoorcset_u[2];
2072 bombdoorcombo_d[2];
2073 bombdoorcset_d[2];
2074 bombdoorcombo_l[3];
2075 bombdoorcset_l[3];
2076 bombdoorcombo_r[3];
2077 bombdoorcset_r[3];
2078 walkthroughcombo[4];
2079 walkthroughcset[4];
2080 */
2081 7072 }
2082
2083 905216 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
2084 {
2085 905216 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
2086 }
2087
2088 905216 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
2089 {
2090
2091 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
2092 }
2093
2094 905216 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
2095 {
2096 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
2097 }
2098
2099
2100 16 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
2101 {
2102 char temp_pwd[30];
2103 16 memset(temp_pwd,0,30);
2104
2105
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(pwdkey!=0)
2106 {
2107 16 memcpy(temp_pwd,encrypted_pwd,30);
2108 16 temp_pwd[29]=0;
2109
2110
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 16 times.
496 for(int32_t i=0; i<30; i++)
2111 {
2112 480 temp_pwd[i] -= pwdkey;
2113 480 int32_t t=pwdkey>>15;
2114 480 pwdkey = (pwdkey<<1)+t;
2115 480 }
2116 16 }
2117
2118 16 memcpy(pwd,temp_pwd,30);
2119 16 }
2120
2121
2122 92 bool devpwd()
2123 {
2124 #ifdef _DEBUG
2125 return true;
2126 #endif
2127 92 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio);
2128 }
2129 bool check_questpwd(zquestheader *Header, char *pwd)
2130 {
2131 #if DEVLEVEL > 3
2132 return true;
2133 #endif
2134
2135 if (devpwd()) return true;
2136 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
2137 cvs_MD5Context ctx;
2138 uint8_t md5sum[16];
2139
2140 cvs_MD5Init(&ctx);
2141 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2142 cvs_MD5Final(md5sum, &ctx);
2143
2144 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2145 }
2146
2147 115 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2148 {
2149 115 zprint2("\n");
2150 115 zprint2("[ZQUEST CREATOR METADATA]\n");
2151
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(qst_num < moduledata.max_quest_files)
2152 zprint2("Loading module quest %d\n", qst_num+1);
2153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(path) zprint2("Loading '%s'\n", path);
2154
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
115 if ( tempheader.new_version_id_main > 0 )
2155 {
2156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(tempheader.new_version_id_fourth > 0)
2157 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2158 tempheader.new_version_id_main,tempheader.new_version_id_second,
2159 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2160 111 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2161 111 tempheader.new_version_id_main,tempheader.new_version_id_second,
2162 111 tempheader.new_version_id_third);
2163 111 }
2164 else
2165 {
2166
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 switch ( tempheader.zelda_version )
2167 {
2168 case 0x255:
2169 {
2170 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2171 break;
2172 }
2173 case 0x254:
2174 {
2175 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2176 break;
2177 }
2178 case 0x250:
2179 {
2180 switch(tempheader.build)
2181 {
2182 case 19:
2183 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2184 case 20:
2185 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2186 case 21:
2187 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2188 case 22:
2189 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2190 case 23:
2191 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2192 case 24:
2193 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2194 case 25:
2195 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2196 case 26:
2197 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2198 case 27:
2199 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2200 case 28:
2201 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2202 case 29:
2203 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2204 case 30:
2205 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2206 case 31:
2207 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2208 case 32:
2209 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2210 case 33:
2211 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2212 default:
2213 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2214
2215 }
2216 break;
2217 }
2218
2219 case 0x211:
2220 {
2221 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2222 }
2223 case 0x210:
2224 {
2225 zprint2("Last saved in ZQuest Version: 2.10.x");
2226 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2227 break;
2228 }
2229 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2230 case 0x193:
2231 {
2232 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2233 }
2234 case 0x192:
2235 {
2236 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2237 }
2238 case 0x190:
2239 {
2240 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2241 }
2242 case 0x184:
2243 {
2244 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2245 }
2246 case 0x183:
2247 {
2248 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2249 }
2250 case 0x180:
2251 {
2252 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2253 }
2254 default:
2255 {
2256 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2257 }
2258 */
2259 }
2260 }
2261
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
115 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2262 22 zprint2("%s\n", tempheader.getAlphaVerStr());
2263 93 else zprint2("\n");
2264
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 22 times.
115 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2265
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 22 times.
115 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2266
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 22 times.
115 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2267
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 22 times.
115 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2268
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 111 times.
115 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2269
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 22 times.
115 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2270 115 zprint2("\n");
2271 115 }
2272
2273 123 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
2274 {
2275 int32_t dummy;
2276 zquestheader tempheader;
2277 char dummybuf[80];
2278 byte temp_map_count;
2279 byte temp_midi_flags[MIDIFLAGS_SIZE];
2280 word version;
2281 char temp_pwd[30], temp_pwd2[30];
2282 int16_t temp_pwdkey;
2283 cvs_MD5Context ctx;
2284 123 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2285 123 memset(&tempheader, 0, sizeof(tempheader));
2286 123 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2287
2288
2289
2290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
2291 {
2292 Z_message("Unable to read header string\n");
2293 return qe_invalid;
2294 }
2295
2296 // check header
2297
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
123 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2298 {
2299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2300 {
2301 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2302 return qe_invalid;
2303 }
2304 4 }
2305
2306 123 int32_t templatepath_len=0;
2307
2308 123 tempheader.external_zinfo = false;
2309 123 read_zinfo = false;
2310
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
123 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2311 {
2312 byte padding;
2313
2314
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f))
2315 {
2316 return qe_invalid;
2317 }
2318
2319
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.zelda_version,f))
2320 {
2321 return qe_invalid;
2322 }
2323
2324 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2325
2326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version > ZELDA_VERSION)
2327 {
2328 return qe_version;
2329 }
2330
2331 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2332
2333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2334 {
2335 return qe_invalid;
2336 }
2337
2338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(bad_version(tempheader.zelda_version))
2339 {
2340 return qe_obsolete;
2341 }
2342
2343
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.internal,f))
2344 {
2345 return qe_invalid;
2346 }
2347
2348
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.quest_number,f))
2349 {
2350 return qe_invalid;
2351 }
2352
2353 4 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2354
2355
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[0],2,f))
2356 {
2357 return qe_invalid;
2358 }
2359
2360
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_map_count,f))
2361 {
2362 return qe_invalid;
2363 }
2364
2365 4 FFCore.quest_format[qMapCount] = temp_map_count;
2366
2367
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.old_str_count,f))
2368 {
2369 return qe_invalid;
2370 }
2371
2372
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2373 {
2374 return qe_invalid;
2375 }
2376
2377
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_midi_flags,4,f))
2378 {
2379 return qe_invalid;
2380 }
2381
2382
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2383 {
2384 return qe_invalid;
2385 }
2386
2387
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,14,f))
2388 {
2389 return qe_invalid;
2390 }
2391
2392
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[2],2,f))
2393 {
2394 return qe_invalid;
2395 }
2396
2397
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&dummybuf,f))
2398 {
2399 return qe_invalid;
2400 }
2401
2402
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.version,9,f))
2403 {
2404 return qe_invalid;
2405 }
2406
2407
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2408 {
2409 return qe_invalid;
2410 }
2411 // These fields are expected to end in null bytes!
2412 4 tempheader.title[sizeof(tempheader.title)-1] = 0;
2413
2414
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2415 {
2416 return qe_invalid;
2417 }
2418 4 tempheader.author[sizeof(tempheader.author)-1] = 0;
2419
2420
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f))
2421 {
2422 return qe_invalid;
2423 }
2424
2425
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&temp_pwdkey,f))
2426 {
2427 return qe_invalid;
2428 }
2429
2430
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_pwd,30,f))
2431 {
2432 return qe_invalid;
2433 }
2434
2435 4 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2436 4 cvs_MD5Init(&ctx);
2437 4 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2438 4 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2439
2440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2441 {
2442 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2443 // Not anymore...
2444 memset(tempheader.minver,0,17);
2445 tempheader.build=0;
2446 tempheader.use_keyfile=0;
2447 memset(tempheader.old_foo, 0, 9);
2448 }
2449 else
2450 {
2451
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.minver,9,f))
2452 {
2453 return qe_invalid;
2454 }
2455
2456
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.build,f))
2457 {
2458 return qe_invalid;
2459 }
2460
2461 4 FFCore.quest_format[vBuild] = tempheader.build;
2462
2463
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.use_keyfile,f))
2464 {
2465 return qe_invalid;
2466 }
2467
2468
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,9,f))
2469 {
2470 return qe_invalid;
2471 }
2472 } // starting at minver
2473
2474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2475 {
2476 memset(&quest_rules[4],0,16); // word rules3..rules10
2477 }
2478 else
2479 {
2480
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2481 {
2482 return qe_invalid; // starting at rules3
2483 }
2484
2485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version <= 0x190)
2486 {
2487 4 set_qr(qr_MEANPLACEDTRAPS,0);
2488 4 }
2489 }
2490
2491
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2492 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2493 {
2494 4 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2495 4 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2496 4 set_qr(qr_BRKBLSHLDS_DEP,1);
2497 4 }
2498
2499
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2500 {
2501 byte *mf=temp_midi_flags;
2502
2503 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2504 {
2505 mf=(byte*)dummybuf;
2506 }
2507
2508 if(!pfread(mf,32,f)) // read new header additions
2509 {
2510 return qe_invalid; // starting at foo2
2511 }
2512
2513 if(!pfread(dummybuf,18,f)) // read new header additions
2514 {
2515 return qe_invalid; // starting at foo2
2516 }
2517 }
2518
2519
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2520 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2521 {
2522 4 memset(tempheader.templatepath,0,2048);
2523 4 }
2524 else
2525 {
2526 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2527 {
2528 return qe_invalid;
2529 }
2530 }
2531
2532
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2533 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2534 {
2535 4 tempheader.use_keyfile=0;
2536 4 }
2537 4 }
2538 else
2539 {
2540 //section id
2541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(!p_mgetl(&dummy,f))
2542 {
2543 return qe_invalid;
2544 }
2545
2546 //section version info
2547
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&version,f))
2548 {
2549 return qe_invalid;
2550 }
2551
2552 119 FFCore.quest_format[vHeader] = version;
2553
2554
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&dummy,f))
2555 {
2556 return qe_invalid;
2557 }
2558
2559 //section size
2560
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetl(&dummy,f))
2561 {
2562 return qe_invalid;
2563 }
2564
2565 //finally... section data
2566
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&tempheader.zelda_version,f))
2567 {
2568 return qe_invalid;
2569 }
2570
2571 119 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2572
2573 //do some quick checking...
2574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(tempheader.zelda_version > ZELDA_VERSION)
2575 {
2576 return qe_version;
2577 }
2578
2579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2580 {
2581 return qe_invalid;
2582 }
2583
2584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(bad_version(tempheader.zelda_version))
2585 {
2586 return qe_obsolete;
2587 }
2588
2589
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&tempheader.build,f))
2590 {
2591 return qe_invalid;
2592 }
2593
2594 119 FFCore.quest_format[vBuild] = tempheader.build;
2595
2596
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 107 times.
119 if(version<3)
2597 {
2598
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!pfread(temp_pwd,30,f))
2599 {
2600 return qe_invalid;
2601 }
2602
2603
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&temp_pwdkey,f))
2604 {
2605 return qe_invalid;
2606 }
2607
2608 12 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2609 12 cvs_MD5Init(&ctx);
2610 12 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2611 12 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2612 12 }
2613 else
2614 {
2615
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2616 {
2617 return qe_invalid;
2618 }
2619 }
2620
2621
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&tempheader.internal,f))
2622 {
2623 return qe_invalid;
2624 }
2625
2626
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&tempheader.quest_number,f))
2627 {
2628 return qe_invalid;
2629 }
2630
2631 119 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2632
2633 119 size_t versz = version < 8 ? 9 : 16;
2634
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!pfread(tempheader.version,versz,f))
2635 {
2636 return qe_invalid;
2637 }
2638
2639 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2640 //needs to be copied as char[9] or stored as a s.str
2641
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!pfread(tempheader.minver,versz,f))
2642 {
2643 return qe_invalid;
2644 }
2645
2646 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2647
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2648 {
2649 return qe_invalid;
2650 }
2651 119 tempheader.title[sizeof(tempheader.title)-1] = 0;
2652
2653
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2654 {
2655 return qe_invalid;
2656 }
2657 119 tempheader.author[sizeof(tempheader.author)-1] = 0;
2658
2659
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&tempheader.use_keyfile,f))
2660 {
2661 return qe_invalid;
2662 }
2663
2664 /*
2665 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2666 {
2667 return qe_invalid;
2668 }
2669 */
2670
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2671 {
2672 return qe_invalid;
2673 }
2674
2675
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!pfread(&dummybuf,4,f))
2676 {
2677 return qe_invalid;
2678 }
2679
2680
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2681 {
2682 return qe_invalid;
2683 }
2684
2685
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!pfread(dummybuf,14,f))
2686 {
2687 return qe_invalid;
2688 }
2689
2690 119 templatepath_len=sizeof(tempheader.templatepath);
2691
2692
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 12 times.
119 if(version==1)
2693 {
2694 12 templatepath_len=280;
2695 12 }
2696
2697
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!pfread(tempheader.templatepath,templatepath_len,f))
2698 {
2699 return qe_invalid;
2700 }
2701
2702
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_map_count,f))
2703 {
2704 return qe_invalid;
2705 }
2706
2707
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 89 times.
119 if(version>=4)
2708 {
2709
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.new_version_id_main,f))
2710 {
2711 return qe_invalid;
2712 }
2713
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.new_version_id_second,f))
2714 {
2715 return qe_invalid;
2716 }
2717
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.new_version_id_third,f))
2718 {
2719 return qe_invalid;
2720 }
2721
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2722 {
2723 return qe_invalid;
2724 }
2725
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2726 {
2727 return qe_invalid;
2728 }
2729
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.new_version_id_beta,f))
2730 {
2731 return qe_invalid;
2732 }
2733
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2734 {
2735 return qe_invalid;
2736 }
2737
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.new_version_id_release,f))
2738 {
2739 return qe_invalid;
2740 }
2741
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2742 {
2743 return qe_invalid;
2744 }
2745
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&tempheader.new_version_id_date_month,f))
2746 {
2747 return qe_invalid;
2748 }
2749
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&tempheader.new_version_id_date_day,f))
2750 {
2751 return qe_invalid;
2752 }
2753
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2754 {
2755 return qe_invalid;
2756 }
2757
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2758 {
2759 return qe_invalid;
2760 }
2761
2762
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!pfread(tempheader.new_version_devsig,256,f))
2763 {
2764 return qe_invalid;
2765 }
2766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2767 strcpy(tempheader.new_version_devsig, "EmilyV99");
2768
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!pfread(tempheader.new_version_compilername,256,f))
2769 {
2770 return qe_invalid;
2771 }
2772
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!pfread(tempheader.new_version_compilerversion,256,f))
2773 {
2774 return qe_invalid;
2775 }
2776
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!pfread(tempheader.product_name,1024,f))
2777 {
2778 return qe_invalid;
2779 }
2780
2781
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&tempheader.compilerid,f))
2782 {
2783 return qe_invalid;
2784 }
2785
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2786 {
2787 return qe_invalid;
2788 }
2789
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2790 {
2791 return qe_invalid;
2792 }
2793
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2794 {
2795 return qe_invalid;
2796 }
2797
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2798 {
2799 return qe_invalid;
2800 }
2801
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetw(&tempheader.developerid,f))
2802 {
2803 return qe_invalid;
2804 }
2805
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!pfread(tempheader.made_in_module_name,1024,f))
2806 {
2807 return qe_invalid;
2808 }
2809
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!pfread(tempheader.build_datestamp,256,f))
2810 {
2811 return qe_invalid;
2812 }
2813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(!pfread(tempheader.build_timestamp,256,f))
2814 {
2815 return qe_invalid;
2816 }
2817 30 }
2818 else // <4
2819 {
2820 89 tempheader.new_version_id_main = 0;
2821 89 tempheader.new_version_id_second = 0;
2822 89 tempheader.new_version_id_third = 0;
2823 89 tempheader.new_version_id_fourth = 0;
2824 89 tempheader.new_version_id_alpha = 0;
2825 89 tempheader.new_version_id_beta = 0;
2826 89 tempheader.new_version_id_gamma = 0;
2827 89 tempheader.new_version_id_release = 0;
2828 89 tempheader.new_version_id_date_year = 0;
2829 89 tempheader.new_version_id_date_month = 0;
2830 89 tempheader.new_version_id_date_day = 0;
2831 89 tempheader.new_version_id_date_hour = 0;
2832 89 tempheader.new_version_id_date_minute = 0;
2833
2834 89 memset(tempheader.new_version_devsig, 0, 256);
2835 89 memset(tempheader.new_version_compilername, 0, 256);
2836 89 memset(tempheader.new_version_compilerversion, 0, 256);
2837 89 memset(tempheader.product_name, 0, 1024);
2838 89 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2839
2840 89 tempheader.compilerid = 0;
2841 89 tempheader.compilerversionnumber_first = 0;
2842 89 tempheader.compilerversionnumber_second = 0;
2843 89 tempheader.compilerversionnumber_third = 0;
2844 89 tempheader.compilerversionnumber_fourth = 0;
2845 89 tempheader.developerid = 0;
2846
2847 89 memset(tempheader.made_in_module_name, 0, 1024);
2848 89 memset(tempheader.build_datestamp, 0, 256);
2849 89 memset(tempheader.build_timestamp, 0, 256);
2850 }
2851
2852
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 89 times.
119 if ( version >= 5 )
2853 {
2854
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!pfread(tempheader.build_timezone,6,f))
2855 {
2856 return qe_invalid;
2857 }
2858 30 }
2859 else // < 5
2860 {
2861 89 memset(tempheader.build_timezone, 0, 6);
2862 }
2863
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 30 times.
119 if ( version >= 6 )
2864 {
2865 byte b;
2866
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&b,f))
2867 {
2868 return qe_invalid;
2869 }
2870 30 tempheader.external_zinfo = b?true:false;
2871 30 read_zinfo = true;
2872 30 }
2873
2874
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 89 times.
119 if(version >= 7)
2875 {
2876
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2877 {
2878 return qe_invalid;
2879 }
2880 30 }
2881 else
2882 {
2883 89 tempheader.new_version_is_nightly = false;
2884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(tempheader.zelda_version < 0x255)
2885 {
2886
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
89 switch(tempheader.zelda_version)
2887 {
2888 case 0x254:
2889 tempheader.new_version_id_main = 2;
2890 tempheader.new_version_id_second = 54;
2891 break;
2892 case 0x250:
2893
6/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 24 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 10 times.
✓ Branch 15 taken 1 times.
77 switch(tempheader.build)
2894 {
2895 case 19:
2896 tempheader.new_version_id_main = 2;
2897 tempheader.new_version_id_second = 50;
2898 tempheader.new_version_id_gamma = 1;
2899 break;
2900 case 20:
2901 tempheader.new_version_id_main = 2;
2902 tempheader.new_version_id_second = 50;
2903 tempheader.new_version_id_gamma = 2;
2904 break;
2905 case 21:
2906 tempheader.new_version_id_main = 2;
2907 tempheader.new_version_id_second = 50;
2908 tempheader.new_version_id_gamma = 3;
2909 break;
2910 case 22:
2911 tempheader.new_version_id_main = 2;
2912 tempheader.new_version_id_second = 50;
2913 tempheader.new_version_id_gamma = 4;
2914 break;
2915 case 23:
2916 tempheader.new_version_id_main = 2;
2917 tempheader.new_version_id_second = 50;
2918 tempheader.new_version_id_gamma = 5;
2919 break;
2920 case 24:
2921 22 tempheader.new_version_id_main = 2;
2922 22 tempheader.new_version_id_second = 50;
2923 22 tempheader.new_version_id_release = -1;
2924 22 break;
2925 case 25:
2926 tempheader.new_version_id_main = 2;
2927 tempheader.new_version_id_second = 50;
2928 tempheader.new_version_id_third = 1;
2929 tempheader.new_version_id_gamma = 1;
2930 break;
2931 case 26:
2932 tempheader.new_version_id_main = 2;
2933 tempheader.new_version_id_second = 50;
2934 tempheader.new_version_id_third = 1;
2935 tempheader.new_version_id_gamma = 2;
2936 break;
2937 case 27:
2938 tempheader.new_version_id_main = 2;
2939 tempheader.new_version_id_second = 50;
2940 tempheader.new_version_id_third = 1;
2941 tempheader.new_version_id_gamma = 3;
2942 break;
2943 case 28:
2944 5 tempheader.new_version_id_main = 2;
2945 5 tempheader.new_version_id_second = 50;
2946 5 tempheader.new_version_id_third = 1;
2947 5 tempheader.new_version_id_release = -1;
2948 5 break;
2949 case 29:
2950 24 tempheader.new_version_id_main = 2;
2951 24 tempheader.new_version_id_second = 50;
2952 24 tempheader.new_version_id_third = 2;
2953 24 tempheader.new_version_id_release = -1;
2954 24 break;
2955 case 30:
2956 tempheader.new_version_id_main = 2;
2957 tempheader.new_version_id_second = 50;
2958 tempheader.new_version_id_third = 3;
2959 tempheader.new_version_id_gamma = 1;
2960 break;
2961 case 31:
2962 15 tempheader.new_version_id_main = 2;
2963 15 tempheader.new_version_id_second = 53;
2964 15 tempheader.new_version_id_gamma = -1;
2965 15 break;
2966 case 32:
2967 10 tempheader.new_version_id_main = 2;
2968 10 tempheader.new_version_id_second = 53;
2969 10 tempheader.new_version_id_release = -1;
2970 10 break;
2971 case 33:
2972 1 tempheader.new_version_id_main = 2;
2973 1 tempheader.new_version_id_second = 53;
2974 1 tempheader.new_version_id_third = 1;
2975 1 break;
2976 }
2977 77 break;
2978
2979 case 0x211:
2980 tempheader.new_version_id_main = 2;
2981 tempheader.new_version_id_second = 11;
2982 tempheader.new_version_id_beta = tempheader.build;
2983 break;
2984 case 0x210:
2985 12 tempheader.new_version_id_main = 2;
2986 12 tempheader.new_version_id_second = 10;
2987 12 tempheader.new_version_id_beta = tempheader.build;
2988 12 break;
2989 }
2990 89 }
2991 }
2992
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
119 if(printmetadata || __isZQuest)
2993 {
2994 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2995 }
2996 }
2997
2998 //{ Version Warning
2999 123 int32_t vercmp = tempheader.compareVer();
3000 123 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
3001 123 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
3002
4/6
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
153 if(vercmp > 0 || (!vercmp &&
3003
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 (astatecmp > 0 || (!astatecmp &&
3004 30 avercmp > 0))))
3005 {
3006 bool r = true;
3007 if(loadquest_report)
3008 {
3009 enter_sys_pal();
3010 AlertDialog("Quest saved in newer version",
3011 "This quest was last saved in a newer version of ZQuest."
3012 " Attempting to load this quest may not work correctly; to"
3013 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
3014 "\n\nWould you like to continue loading anyway? (Not recommended)",
3015 [&](bool ret,bool)
3016 {
3017 r = ret;
3018 }).show();
3019 exit_sys_pal();
3020 }
3021 if(!r)
3022 return qe_silenterr;
3023 }
3024
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 else if(tempheader.compareDate() > 0)
3025 {
3026 bool r = true;
3027 if(loadquest_report)
3028 {
3029 enter_sys_pal();
3030 AlertDialog("Quest saved in newer build",
3031 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
3032 " issues loading in this build."
3033 "\n{}"
3034 "\n\nWould you like to continue loading anyway?",
3035 tempheader.getVerCmpStr()),
3036 [&](bool ret,bool)
3037 {
3038 r = ret;
3039 }).show();
3040 exit_sys_pal();
3041 }
3042 if(!r)
3043 return qe_silenterr;
3044 }
3045 //}
3046
3047 123 read_ext_zinfo = tempheader.external_zinfo;
3048
3049 123 memcpy(Header, &tempheader, sizeof(tempheader));
3050 123 map_count=temp_map_count;
3051 123 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
3052
3053 123 return 0;
3054 123 }
3055
3056 125 int32_t readrules(PACKFILE *f, zquestheader *Header)
3057 {
3058 int32_t dummy;
3059 zquestheader tempheader;
3060 125 word s_version=0;
3061 125 dword compatrule_version=0;
3062
3063 125 memcpy(&tempheader, Header, sizeof(tempheader));
3064
3065
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 119 times.
125 if(tempheader.zelda_version >= 0x193)
3066 {
3067 //section version info
3068
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&s_version,f))
3069 {
3070 return qe_invalid;
3071 }
3072
3073 119 FFCore.quest_format[vRules] = s_version;
3074
3075
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&dummy,f))
3076 {
3077 return qe_invalid;
3078 }
3079
3080
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 30 times.
119 if(s_version > 16)
3081 {
3082
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&compatrule_version,f))
3083 {
3084 return qe_invalid;
3085 }
3086 30 }
3087 119 FFCore.quest_format[vCompatRule] = compatrule_version;
3088
3089 //section size
3090
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetl(&dummy,f))
3091 {
3092 return qe_invalid;
3093 }
3094
3095
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 30 times.
119 if ( s_version < 15 )
3096 {
3097 //finally... section data
3098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
3099 {
3100 return qe_invalid;
3101 }
3102 89 }
3103 else
3104 {
3105
3106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
3107 {
3108 return qe_invalid;
3109 }
3110
3111 }
3112 119 }
3113
3114 //al_trace("Rules version %d\n", s_version);
3115 //{ bunch of compat stuff
3116 125 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
3117
3118
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 16 times.
125 if(s_version<2)
3119 {
3120 16 set_qr(14,0);
3121 16 set_qr(27,0);
3122 16 set_qr(28,0);
3123 16 set_qr(29,0);
3124 16 set_qr(30,0);
3125 16 set_qr(32,0);
3126 16 set_qr(36,0);
3127 16 set_qr(49,0);
3128 16 set_qr(50,0);
3129 16 set_qr(51,0);
3130 16 set_qr(68,0);
3131 16 set_qr(75,0);
3132 16 set_qr(76,0);
3133 16 set_qr(98,0);
3134 16 set_qr(110,0);
3135 16 set_qr(113,0);
3136 16 set_qr(116,0);
3137 16 set_qr(102,0);
3138 16 set_qr(132,0);
3139 16 }
3140
3141 //Now, do any updates...
3142
5/6
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
125 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3143 {
3144 20 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
3145 20 set_qr(qr_REPLACEOPENDOORS, 1);
3146 20 set_qr(qr_OLDLENSORDER, 1);
3147 20 set_qr(qr_NOFAIRYGUYFIRES, 1);
3148 20 set_qr(qr_TRIGGERSREPEAT, 1);
3149 20 }
3150
3151
5/6
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
125 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3152 {
3153 8 set_qr(qr_WALLFLIERS,1);
3154 8 }
3155
3156
5/6
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
125 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3157 {
3158 8 set_qr(qr_NOBOMBPALFLASH,1);
3159 8 }
3160
3161
5/6
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
125 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3162 {
3163 8 set_qr(qr_NOSCROLLCONTINUE,1);
3164 8 }
3165
3166
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 16 times.
125 if(tempheader.zelda_version <= 0x210)
3167 {
3168 16 set_qr(qr_ARROWCLIP,1);
3169 16 }
3170
3171
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(tempheader.zelda_version == 0x210)
3172 {
3173 12 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
3174 12 set_qr(qr_CMBCYCLELAYERS, 0);
3175 12 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
3176 12 }
3177
3178
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 16 times.
125 if(tempheader.zelda_version <= 0x210)
3179 {
3180 16 set_qr(qr_OLDSTYLEWARP,1);
3181 16 set_qr(qr_210_WARPRETURN,1);
3182 16 }
3183
3184 //might not be correct
3185
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 4 times.
125 if(tempheader.zelda_version < 0x210)
3186 {
3187 4 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3188 4 set_qr(qr_OLDTRIBBLES_DEP,1);
3189 4 set_qr(qr_OLDHOOKSHOTGRAB,1);
3190 4 }
3191
3192
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 16 times.
125 if(tempheader.zelda_version < 0x211)
3193 {
3194 16 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
3195 16 }
3196
3197
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
125 if(tempheader.zelda_version == 0x192 && tempheader.build == 163)
3198 {
3199 set_qr(qr_192b163_WARP,1);
3200 }
3201
3202
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(tempheader.zelda_version == 0x210)
3203 {
3204 12 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3205 12 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3206 12 set_qr(qr_DMGCOMBOPRI, 0);
3207 12 }
3208
3209
5/6
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
125 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3210 {
3211 20 set_qr(qr_OLDPICKUP,1);
3212 20 }
3213
3214
5/6
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
125 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3215 {
3216 20 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
3217 20 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3218 20 }
3219
3220
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 16 times.
125 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3221 {
3222 16 set_qr(qr_HOOKSHOTDOWNBUG, 1);
3223 16 }
3224
3225
4/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 22 times.
125 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3226 {
3227 22 set_qr(qr_PEAHATCLOCKVULN, 1);
3228 22 }
3229
3230
6/6
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 79 times.
125 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3231 {
3232 20 set_qr(qr_OLD_DOORREPAIR, 1);
3233 20 }
3234
3235
6/6
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 79 times.
125 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3236 {
3237 20 set_qr(qr_OLD_SECRETMONEY, 1);
3238 20 }
3239
3240
6/6
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 57 times.
125 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3241 {
3242 42 set_qr(qr_OLD_POTION_OR_HC, 1);
3243 42 }
3244
3245
6/6
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 57 times.
125 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3246 {
3247 42 set_qr(qr_OFFSCREENWEAPONS, 1);
3248 42 }
3249
3250 //Bombchu fix.
3251
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 77 times.
125 if(tempheader.zelda_version == 0x250)
3252 {
3253
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 22 times.
77 if ( tempheader.build == 24 ) //2.50.0
3254 {
3255 22 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3256 22 }
3257
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 5 times.
77 if ( tempheader.build == 28 ) //2.50.1
3258 {
3259 5 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3260 5 }
3261
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 24 times.
77 if ( tempheader.build == 29 ) //2.50.2
3262 {
3263 24 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3264 24 }
3265
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if ( tempheader.build == 30 ) //2.50.3RC1
3266 {
3267 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3268 }
3269 77 }
3270
3271
6/6
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 29 times.
✓ Branch 5 taken 52 times.
125 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3272 {
3273 // qr_OFFSETEWPNCOLLISIONFIX
3274 // All 'official' quests need this disabled.
3275 // All 2.10 and lower quests need this enabled to preseve compatability.
3276 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3277
3278 //~Gleeok
3279 47 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3280
3281 // Broke in build 695
3282
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
47 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3283 27 set_qr(qr_BROKENSTATUES, 1);
3284 43 }
3285
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 4 times.
125 if (tempheader.zelda_version <= 0x190)
3286 {
3287 4 set_qr(qr_COPIED_SWIM_SPRITES, 1);
3288 4 }
3289
9/10
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 31 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 30 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 30 times.
125 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3290 {
3291 94 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
3292 94 }
3293
3294
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3295 {
3296 16 set_qr(qr_OLD_210_WATER, 1);
3297 16 }
3298
3299
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3300 {
3301 93 set_qr(qr_STEP_IS_FLOAT,0);
3302 93 }
3303
3304
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if ( tempheader.zelda_version < 0x250 )
3305 {
3306 16 set_qr(qr_8WAY_SHOT_SFX, 1);
3307 16 }
3308
3309
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if(s_version < 3)
3310 {
3311 16 set_qr(qr_HOLDNOSTOPMUSIC, 1);
3312 16 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
3313 16 }
3314
3315
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if(s_version<4)
3316 {
3317 16 set_qr(10,0);
3318 16 }
3319
3320
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if(s_version<5)
3321 {
3322 16 set_qr(27,0);
3323 16 }
3324
3325
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if(s_version<6)
3326 {
3327 16 set_qr(46,0);
3328 16 }
3329
3330
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if(s_version<7) // January 2008
3331 {
3332 16 set_qr(qr_HEARTSREQUIREDFIX,0);
3333 16 set_qr(qr_PUSHBLOCKCSETFIX,1);
3334 16 }
3335
3336
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 107 times.
123 if(s_version<8)
3337 {
3338 16 set_qr(12, 0);
3339 16 }
3340 else
3341 {
3342 107 set_bit(deprecated_rules, 12, 0);
3343 }
3344
3345
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if(s_version<9) // October 2008
3346 {
3347 16 set_qr(qr_NOROPE2FLASH_DEP,0);
3348 16 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3349 16 set_qr(qr_GHINI2BLINK_DEP,0);
3350 16 set_qr(qr_PHANTOMGHINI2_DEP,0);
3351 16 }
3352
3353
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if(s_version<10) // December 2008
3354 {
3355 16 set_qr(qr_NOCLOCKS_DEP,0);
3356 16 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3357 16 }
3358
3359
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if(s_version<11) // April 2009
3360 {
3361 16 set_qr(qr_SLOWENEMYANIM_DEP,0);
3362 16 }
3363
3364 // This served no purpose.
3365 // if(s_version<12) // December 2009
3366 // {
3367 // set_qr(qr_BRKBLSHLDS_DEP,0);
3368 // set_qr(qr_OLDTRIBBLES_DEP,0);
3369 // }
3370
3371 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3372
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if(s_version < 13)
3373 {
3374 16 set_qr(qr_SHOPCHEAT, 1);
3375 16 }
3376
3377 // Not entirely sure this is the best place for this...
3378 //2.50.2 bitmap offset fix
3379 123 memset(extra_rules, 0, EXTRARULES_SIZE);
3380
6/6
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 50 times.
123 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3381 {
3382 43 set_er(er_BITMAPOFFSET, 1);
3383 43 set_qr(qr_BITMAPOFFSETFIX, 1);
3384 43 }
3385 //required because quest templates also used this bit, although
3386 //it never did anything, before. -Z
3387
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 77 times.
123 if ( tempheader.zelda_version == 0x250 )
3388 {
3389
5/6
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 38 times.
77 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3390 {
3391 39 set_er(er_BITMAPOFFSET, 0);
3392 39 set_qr(qr_BITMAPOFFSETFIX, 0);
3393 39 }
3394 77 }
3395
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if ( tempheader.zelda_version == 0x254 )
3396 {
3397 set_er(er_BITMAPOFFSET, 0);
3398 set_qr(qr_BITMAPOFFSETFIX, 0);
3399 }
3400
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
123 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3401 {
3402 set_er(er_BITMAPOFFSET, 0);
3403 set_qr(qr_BITMAPOFFSETFIX, 0);
3404 }
3405 //optimise fast drawing for older versions.
3406
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3407 {
3408 93 set_qr(qr_OLDSPRITEDRAWS, 1);
3409 93 }
3410 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3411 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3412 //older quests can set the rule by hand. We need a new qst.dat again.
3413
4/6
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3414 {
3415 set_qr(qr_OLDEWPNPARENT, 1);
3416 }
3417
4/6
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3418 {
3419 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3420 }
3421
4/6
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3422 {
3423 set_qr(qr_OLDQUESTMISC, 1);
3424 }
3425
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if ( tempheader.zelda_version < 0x254 )
3426 {
3427 93 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3428 93 set_qr(qr_OLDEWPNPARENT, 0);
3429 93 set_qr(qr_OLDQUESTMISC, 0);
3430 93 }
3431
3432 //item scripts continue to run
3433
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3434 {
3435 93 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3436 93 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3437 93 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3438 93 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3439 93 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3440 93 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3441 93 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3442 93 }
3443
3444
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3445 {
3446 93 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3447 93 }
3448
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3449 {
3450 93 set_qr(qr_TRACESCRIPTIDS, 0);
3451 93 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3452 93 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3453 93 set_qr(qr_PARSER_250DIVISION,1);
3454 93 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3455 93 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3456 93 set_qr(qr_PARSER_FORCE_INLINE,0);
3457 93 set_qr(qr_PARSER_BINARY_32BIT,0);
3458
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 2 times.
93 if ( get_qr(qr_SELECTAWPN) )
3459 {
3460 2 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3461 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3462 //Now they **do**, unless you disable that behaviour.
3463 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3464 //now enable the disable L/R item swap on load.
3465 2 }
3466
3467 93 }
3468
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3469 {
3470 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3471 93 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3472 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3473 //animations ending earlier than they should.
3474 93 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3475 //Enemies would ignore solidity on the top half of combos
3476 93 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3477 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3478 93 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3479 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3480 93 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3481 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3482 93 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3483 93 }
3484
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if ( tempheader.zelda_version < 0x255 )
3485 {
3486 93 set_qr(qr_NOFFCWAITDRAW, 1);
3487 93 set_qr(qr_NOITEMWAITDRAW, 1);
3488 93 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3489 93 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3490 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3491 93 }
3492
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3493 {
3494 93 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3495 93 }
3496
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3497 {
3498 93 set_qr(qr_OLD_PRINTF_ARGS, 1);
3499 93 }
3500
3501
3502
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3503 {
3504 93 set_qr(qr_BROKEN_RING_POWER, 1);
3505 93 }
3506
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3507 {
3508 93 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3509 93 }
3510
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3511 {
3512 93 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3513 93 }
3514
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3515 {
3516 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3517
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(get_qr(qr_SET_XBUTTON_ITEMS))
3518 set_qr(qr_SET_YBUTTON_ITEMS,1);
3519 93 }
3520
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3521 {
3522 93 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3523 93 }
3524
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3525 {
3526 93 set_qr(qr_OLD_CHEST_COLLISION,1);
3527 93 }
3528
3529
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if ( tempheader.zelda_version < 0x254 )
3530 {
3531 93 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3532 93 }
3533 //Sideview spikes in 2.50.0
3534
6/6
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 55 times.
123 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3535 {
3536 38 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3537 38 }
3538 //more 2.50 fixes -Z
3539
6/6
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 26 times.
123 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3540 {
3541 67 set_qr(qr_MELEEMAGICCOST, 0);
3542 67 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3543 67 set_qr(qr_OLDMIRRORCOMBOS, 1);
3544 67 set_qr(qr_BROKENBOOKCOST, 1);
3545 67 set_qr(qr_BROKENCHARINTDRAWING, 1);
3546
3547 67 }
3548
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
123 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3549 {
3550 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3551 set_qr(qr_MELEEMAGICCOST, 1);
3552 }
3553
3554
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
123 if(tempheader.zelda_version < 0x193)
3555 {
3556 4 set_qr(qr_SHORTDGNWALK, 1);
3557 4 }
3558
3559
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(tempheader.zelda_version < 0x255)
3560 {
3561 93 set_qr(qr_OLDINFMAGIC, 1);
3562 93 }
3563
3564
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3565 {
3566 16 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3567 16 }
3568
3569
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3570 {
3571 93 set_qr(qr_OLD_F6,1);
3572 93 }
3573
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3574 {
3575 93 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3576 93 }
3577
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3578 {
3579 93 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3580 93 }
3581
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3582 {
3583 93 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3584 93 }
3585 //}
3586
3587
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3588 93 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3589
3590
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 2) //Old CSet2 Handling
3591 93 set_qr(qr_OLDCS2,1);
3592
3593
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3594 93 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3595
3596
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3597 93 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3598
3599
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 77 times.
123 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3600 77 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3601
3602
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3603 93 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3604
3605
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3606 93 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3607
3608
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3609 93 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3610
3611
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 9)
3612 {
3613 //Hardcoded BS Patras
3614 93 set_qr(qr_HARDCODED_BS_PATRA,1);
3615 //Hardcoded Patra Inner Eye offsets
3616 93 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3617 //Broken 'Big enemy' animation style
3618 93 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3619 //Broken Attribute 31/32
3620 93 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3621 93 }
3622
3623
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 10) //Shared candle use limits
3624 93 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3625
3626
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 11) //No cross-screen return points
3627 93 set_qr(qr_OLD_RESPAWN_POINTS,1);
3628
3629
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 12)
3630 {
3631 //Old fire trail duration
3632 93 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3633 //Old Intro String in Ganon Room Behavior
3634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3635 93 else set_qr(qr_GANONINTRO,1);
3636 93 }
3637
3638
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
123 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3639 set_qr(qr_ANONE_NOANIM,1);
3640
3641
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 14) //Old Bridge Combo Behavior
3642 93 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3643
3644
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 15) //Broken Z3 Animation
3645 93 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3646
3647
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3648 93 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3649
3650
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 17)
3651 {
3652 //Old Quake/DrawYOffset behavior
3653 //set_qr(qr_OLD_DRAWOFFSET,1);
3654 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3655 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3656 93 }
3657
3658
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 18)
3659 {
3660 //Broken DrawScreen Derivative Functions
3661 93 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3662 //Scrolling Cancels Charge
3663 93 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3664 93 }
3665
3666
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3667 93 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3668
3669
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 20)
3670 93 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3671
3672
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 21)
3673 {
3674 93 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3675 93 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3676 93 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3677 93 set_qr(qr_OLD_BUG_NET,1);
3678 93 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3679 93 }
3680
3681
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 22)
3682 93 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3683
3684
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 23)
3685 93 set_qr(qr_OLD_HALF_MAGIC,1);
3686
3687
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 24)
3688 {
3689 93 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3690 93 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3691 93 }
3692
3693
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 25)
3694 {
3695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3696 93 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3697 93 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3698 93 }
3699
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 26)
3700 {
3701 93 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3702 93 set_qr(qr_POLVIRE_NO_SHADOW,1);
3703 93 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3704 93 }
3705
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3706 {
3707
2/2
✓ Branch 0 taken 27993 times.
✓ Branch 1 taken 93 times.
28086 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3708 27993 set_qr(q,0);
3709
2/2
✓ Branch 0 taken 10416 times.
✓ Branch 1 taken 93 times.
10509 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3710 10416 set_qr(q,0);
3711 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3712 93 }
3713
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 95 times.
123 if(compatrule_version < 28)
3714 95 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3715
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 95 times.
123 if(compatrule_version < 29)
3716 95 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3717
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 95 times.
123 if(compatrule_version < 30)
3718 {
3719 95 set_qr(qr_DECO_2_YOFFSET,1);
3720 95 set_qr(qr_SCREENSTATE_80s_BUG,1);
3721 95 }
3722
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 95 times.
123 if(compatrule_version < 31)
3723 {
3724 95 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3725 95 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3726 95 }
3727
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 95 times.
123 if(compatrule_version < 32)
3728 95 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3729
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 95 times.
123 if(compatrule_version < 33)
3730 95 set_qr(qr_NO_LIFT_SPRITE,1);
3731
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 95 times.
123 if(compatrule_version < 34)
3732 {
3733 95 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3734 95 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3735 95 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3736 95 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3737 95 }
3738
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 96 times.
123 if(compatrule_version < 35)
3739 {
3740 96 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3741 96 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3742 96 }
3743
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 96 times.
123 if(compatrule_version < 36)
3744 96 set_qr(qr_OLD_SHALLOW_SFX,1);
3745
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 98 times.
123 if(compatrule_version < 37)
3746 98 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3747
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 98 times.
123 if(compatrule_version < 38)
3748 98 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3749
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 98 times.
123 if(compatrule_version < 39)
3750 98 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3751
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 98 times.
123 if(compatrule_version < 40)
3752 98 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3753
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 99 times.
123 if(compatrule_version < 41)
3754 99 set_qr(qr_BROKENHITBY,1);
3755
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 99 times.
123 if(compatrule_version < 42)
3756 99 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3757
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 99 times.
123 if(compatrule_version < 43)
3758 99 set_qr(qr_OLD_BOMB_HITBOXES,1);
3759
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 99 times.
123 if(compatrule_version < 44)
3760 99 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3761
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 107 times.
123 if(compatrule_version < 45)
3762 107 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3763
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 107 times.
123 if(compatrule_version < 46)
3764 107 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(compatrule_version < 47)
3766 {
3767 123 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3768 123 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3769 123 }
3770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(compatrule_version < 48)
3771 123 set_qr(qr_OLD_GUY_HANDLING,1);
3772
3773 123 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3774
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if (s_version < 16)
3775 93 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3776
3777 123 memcpy(Header, &tempheader, sizeof(tempheader));
3778
3779 123 return 0;
3780 123 }
3781
3782 1035270 void init_msgstr(MsgStr *str)
3783 {
3784 1035270 str->s = "";
3785 1035270 str->s.shrink_to_fit();
3786 1035270 str->nextstring=0;
3787 1035270 str->tile=0;
3788 1035270 str->cset=0;
3789 1035270 str->trans=false;
3790 1035270 str->font=font_zfont;
3791 1035270 str->y=32;
3792 1035270 str->sfx=18;
3793 1035270 str->listpos=0;
3794 1035270 str->x=24;
3795 1035270 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3796 1035270 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3797 1035270 str->hspace=0;
3798 1035270 str->vspace=0;
3799 1035270 str->stringflags=0;
3800 1035270 str->margins[up] = 8;
3801 1035270 str->margins[down] = 0;
3802 1035270 str->margins[left] = 8;
3803 1035270 str->margins[right] = 0;
3804 1035270 str->portrait_tile = 0;
3805 1035270 str->portrait_cset = 0;
3806 1035270 str->portrait_x = 0;
3807 1035270 str->portrait_y = 0;
3808 1035270 str->portrait_tw = 1;
3809 1035270 str->portrait_th = 1;
3810 1035270 str->shadow_type = 0;
3811 1035270 str->shadow_color = 0;
3812 1035270 str->drawlayer = 6;
3813 1035270 }
3814
3815 123 void init_msgstrings(int32_t start, int32_t end)
3816 {
3817
2/4
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 123 times.
123 if(end <= start || end-start > msg_strings_size)
3818 return;
3819
3820
2/2
✓ Branch 0 taken 1007616 times.
✓ Branch 1 taken 123 times.
1007739 for(int32_t i=start; i<end; i++)
3821 {
3822 1007616 init_msgstr(&MsgStrings[i]);
3823 1007616 MsgStrings[i].listpos=i;
3824 1007616 }
3825
3826
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(start==0)
3827 {
3828 123 MsgStrings[0].s = "(None)";
3829 123 MsgStrings[0].listpos = 0;
3830 123 }
3831 123 }
3832
3833 123 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3834 {
3835 123 MsgStr tempMsgString;
3836
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 init_msgstr(&tempMsgString);
3837
3838 123 word temp_msg_count=0;
3839 word temp_expansion[16];
3840 123 memset(temp_expansion, 0, 16*sizeof(word));
3841 123 char buf[8193] = {0};
3842
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 119 times.
123 if(Header->zelda_version < 0x193)
3843 {
3844 byte tempbyte;
3845 4 int32_t strings_to_read=0;
3846
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3847
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
3848 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3849 {
3850 4 strings_to_read=128;
3851 4 temp_msg_count=Header->old_str_count;
3852
3853 // Some sort of string count corruption seems to be common in old quests
3854
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(temp_msg_count>128)
3855 {
3856 temp_msg_count=128;
3857 }
3858 4 }
3859 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3860 {
3861 strings_to_read=255;
3862 temp_msg_count=Header->old_str_count;
3863 }
3864 else
3865 {
3866 if(!p_igetw(&temp_msg_count,f))
3867 {
3868 return qe_invalid;
3869 }
3870
3871 strings_to_read=temp_msg_count;
3872
3873 if(temp_msg_count >= msg_strings_size)
3874 {
3875 Z_message("Reallocating string buffer...\n");
3876
3877 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3878 // return qe_nomem;
3879
3880 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3881 delete[] MsgStrings;
3882 MsgStrings = new MsgStr[MAXMSGS];
3883 msg_strings_size = MAXMSGS;
3884 for(auto q = 0; q < msg_strings_size; ++q)
3885 {
3886 MsgStrings[q].clear();
3887 }
3888 }
3889 }
3890
3891 //reset the message strings
3892
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 init_msgstrings(0,msg_strings_size);
3893
3894
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t x=0; x<strings_to_read; x++)
3895 {
3896
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 init_msgstr(&tempMsgString);
3897 512 tempMsgString.listpos = x;
3898
3899
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!pfread(buf,73,f))
3900 {
3901 return qe_invalid;
3902 }
3903
3904 512 buf[74] = '\0';
3905
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 tempMsgString.s = buf;
3906
3907
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3908 {
3909 return qe_invalid;
3910 }
3911
3912
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
512 if((Header->zelda_version < 0x192)||
3913 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3914 {
3915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 tempMsgString.nextstring=tempbyte?x+1:0;
3916
3917
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3918 {
3919 return qe_invalid;
3920 }
3921
3922
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3923 {
3924 return qe_invalid;
3925 }
3926 512 }
3927 else
3928 {
3929 if(!p_igetw(&tempMsgString.nextstring,f))
3930 {
3931 return qe_invalid;
3932 }
3933
3934 if(!pfread(temp_expansion,32,f))
3935 {
3936 return qe_invalid;
3937 }
3938 }
3939
3940
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 MsgStrings[x] = tempMsgString;
3941 512 }
3942 4 }
3943 else
3944 {
3945 int32_t dummy_int;
3946 word s_version;
3947 word s_cversion;
3948
3949 //section version info
3950
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!p_igetw(&s_version,f))
3951 {
3952 return qe_invalid;
3953 }
3954
3955 119 FFCore.quest_format[vStrings] = s_version;
3956
3957
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!p_igetw(&s_cversion,f))
3958 {
3959 return qe_invalid;
3960 }
3961
3962 //al_trace("Strings version %d\n", s_version);
3963 //section size
3964
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!p_igetl(&dummy_int,f))
3965 {
3966 return qe_invalid;
3967 }
3968
3969 //finally... section data
3970
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!p_igetw(&temp_msg_count,f))
3971 {
3972 return qe_invalid;
3973 }
3974
3975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(temp_msg_count >= msg_strings_size)
3976 {
3977 Z_message("Reallocating string buffer...\n");
3978
3979 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3980 // return qe_nomem;
3981 delete[] MsgStrings;
3982 MsgStrings = new MsgStr[MAXMSGS];
3983 msg_strings_size = MAXMSGS;
3984 for(auto q = 0; q < msg_strings_size; ++q)
3985 {
3986 MsgStrings[q].clear();
3987 }
3988 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3989 }
3990
3991 //reset the message strings
3992
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 30 times.
119 if(s_version < 7)
3993
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3994
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 init_msgstrings(0,msg_strings_size);
3995
3996 119 int32_t string_length=(s_version<2)?73:145;
3997
3998
2/2
✓ Branch 0 taken 27019 times.
✓ Branch 1 taken 119 times.
27138 for(int32_t i=0; i<temp_msg_count; i++)
3999 {
4000
1/2
✓ Branch 0 taken 27019 times.
✗ Branch 1 not taken.
27019 init_msgstr(&tempMsgString);
4001 27019 tempMsgString.listpos = i;
4002
2/2
✓ Branch 0 taken 880 times.
✓ Branch 1 taken 26139 times.
27019 if(s_version > 8)
4003 {
4004
2/4
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880 times.
✗ Branch 3 not taken.
880 if(!p_igetl(&string_length,f))
4005 {
4006 return qe_invalid;
4007 }
4008 880 }
4009
4010
2/4
✓ Branch 0 taken 27019 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27019 times.
27019 if (string_length < 0 || string_length > 8193)
4011 {
4012 return qe_invalid;
4013 }
4014
4015
2/2
✓ Branch 0 taken 26881 times.
✓ Branch 1 taken 138 times.
27019 if (string_length > 0)
4016 {
4017
2/4
✓ Branch 0 taken 26881 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26881 times.
✗ Branch 3 not taken.
26881 if (!pfread(buf, string_length, f))
4018 {
4019 return qe_invalid;
4020 }
4021 26881 }
4022 else
4023 {
4024 138 buf[0] = 0;
4025 }
4026
4027
2/4
✓ Branch 0 taken 27019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27019 times.
✗ Branch 3 not taken.
27019 if(!p_igetw(&tempMsgString.nextstring,f))
4028 {
4029 return qe_invalid;
4030 }
4031
4032
2/2
✓ Branch 0 taken 19101 times.
✓ Branch 1 taken 7918 times.
27019 if(s_version<2)
4033 {
4034 19101 buf[72] = '\0';
4035
1/2
✓ Branch 0 taken 19101 times.
✗ Branch 1 not taken.
19101 tempMsgString.s = buf;
4036 19101 }
4037 else
4038 {
4039 // June 2008: A bug corrupted the last 4 chars of a string.
4040 // Discard these.
4041
1/2
✓ Branch 0 taken 7918 times.
✗ Branch 1 not taken.
7918 if(s_version<3)
4042 {
4043 for(int32_t j=140; j<144; j++)
4044 {
4045 buf[j] = '\0';
4046 }
4047 }
4048
1/2
✓ Branch 0 taken 7918 times.
✗ Branch 1 not taken.
7918 if(string_length > 8192) string_length = 8192;
4049 7918 buf[string_length]='\0'; //Force-terminate
4050
1/2
✓ Branch 0 taken 7918 times.
✗ Branch 1 not taken.
7918 tempMsgString.s = buf;
4051
4052
2/2
✓ Branch 0 taken 880 times.
✓ Branch 1 taken 7038 times.
7918 if ( s_version >= 6 )
4053 {
4054
2/4
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880 times.
✗ Branch 3 not taken.
880 if(!p_igetl(&tempMsgString.tile,f))
4055 {
4056 return qe_invalid;
4057 }
4058 880 }
4059 else
4060 {
4061
2/4
✓ Branch 0 taken 7038 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7038 times.
✗ Branch 3 not taken.
7038 if(!p_igetw(&tempMsgString.tile,f))
4062 {
4063 return qe_invalid;
4064 }
4065 }
4066
4067
2/4
✓ Branch 0 taken 7918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7918 times.
✗ Branch 3 not taken.
7918 if(!p_getc(&tempMsgString.cset,f))
4068 {
4069 return qe_invalid;
4070 }
4071
4072 byte dummy_char;
4073
4074
2/4
✓ Branch 0 taken 7918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7918 times.
✗ Branch 3 not taken.
7918 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
4075 {
4076 return qe_invalid;
4077 }
4078
4079 7918 tempMsgString.trans=dummy_char!=0;
4080
4081
2/4
✓ Branch 0 taken 7918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7918 times.
✗ Branch 3 not taken.
7918 if(!p_getc(&tempMsgString.font,f))
4082 {
4083 return qe_invalid;
4084 }
4085
4086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7918 times.
7918 if(s_version < 5)
4087 {
4088 if(!p_getc(&tempMsgString.y,f))
4089 {
4090 return qe_invalid;
4091 }
4092 }
4093 else
4094 {
4095
2/4
✓ Branch 0 taken 7918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7918 times.
✗ Branch 3 not taken.
7918 if(!p_igetw(&tempMsgString.x,f))
4096 {
4097 return qe_invalid;
4098 }
4099
4100
2/4
✓ Branch 0 taken 7918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7918 times.
✗ Branch 3 not taken.
7918 if(!p_igetw(&tempMsgString.y,f))
4101 {
4102 return qe_invalid;
4103 }
4104
4105
2/4
✓ Branch 0 taken 7918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7918 times.
✗ Branch 3 not taken.
7918 if(!p_igetw(&tempMsgString.w,f))
4106 {
4107 return qe_invalid;
4108 }
4109
4110
2/4
✓ Branch 0 taken 7918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7918 times.
✗ Branch 3 not taken.
7918 if(!p_igetw(&tempMsgString.h,f))
4111 {
4112 return qe_invalid;
4113 }
4114
4115
2/4
✓ Branch 0 taken 7918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7918 times.
✗ Branch 3 not taken.
7918 if(!p_getc(&tempMsgString.hspace,f))
4116 {
4117 return qe_invalid;
4118 }
4119
4120
2/4
✓ Branch 0 taken 7918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7918 times.
✗ Branch 3 not taken.
7918 if(!p_getc(&tempMsgString.vspace,f))
4121 {
4122 return qe_invalid;
4123 }
4124
4125
2/4
✓ Branch 0 taken 7918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7918 times.
✗ Branch 3 not taken.
7918 if(!p_getc(&tempMsgString.stringflags,f))
4126 {
4127 return qe_invalid;
4128 }
4129 }
4130
4131
2/2
✓ Branch 0 taken 7038 times.
✓ Branch 1 taken 880 times.
7918 if(s_version >= 7)
4132 {
4133
2/2
✓ Branch 0 taken 880 times.
✓ Branch 1 taken 3520 times.
4400 for(int32_t q = 0; q < 4; ++q)
4134 {
4135
2/4
✓ Branch 0 taken 3520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3520 times.
✗ Branch 3 not taken.
3520 if(!p_getc(&tempMsgString.margins[q],f))
4136 {
4137 return qe_invalid;
4138 }
4139 3520 }
4140
4141
2/4
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880 times.
✗ Branch 3 not taken.
880 if(!p_igetl(&tempMsgString.portrait_tile,f))
4142 {
4143 return qe_invalid;
4144 }
4145
4146
2/4
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880 times.
✗ Branch 3 not taken.
880 if(!p_getc(&tempMsgString.portrait_cset,f))
4147 {
4148 return qe_invalid;
4149 }
4150
4151
2/4
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880 times.
✗ Branch 3 not taken.
880 if(!p_getc(&tempMsgString.portrait_x,f))
4152 {
4153 return qe_invalid;
4154 }
4155
4156
2/4
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880 times.
✗ Branch 3 not taken.
880 if(!p_getc(&tempMsgString.portrait_y,f))
4157 {
4158 return qe_invalid;
4159 }
4160
4161
2/4
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880 times.
✗ Branch 3 not taken.
880 if(!p_getc(&tempMsgString.portrait_tw,f))
4162 {
4163 return qe_invalid;
4164 }
4165
4166
2/4
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880 times.
✗ Branch 3 not taken.
880 if(!p_getc(&tempMsgString.portrait_th,f))
4167 {
4168 return qe_invalid;
4169 }
4170 880 }
4171
4172
2/2
✓ Branch 0 taken 880 times.
✓ Branch 1 taken 7038 times.
7918 if(s_version >= 8)
4173 {
4174
2/4
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880 times.
✗ Branch 3 not taken.
880 if(!p_getc(&tempMsgString.shadow_type,f))
4175 {
4176 return qe_invalid;
4177 }
4178
4179
2/4
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880 times.
✗ Branch 3 not taken.
880 if(!p_getc(&tempMsgString.shadow_color,f))
4180 {
4181 return qe_invalid;
4182 }
4183 880 }
4184
4185
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 7155 times.
7918 if(s_version >= 10)
4186 {
4187
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_getc(&tempMsgString.drawlayer,f))
4188 {
4189 return qe_invalid;
4190 }
4191 763 }
4192
4193
2/4
✓ Branch 0 taken 7918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7918 times.
✗ Branch 3 not taken.
7918 if(!p_getc(&tempMsgString.sfx,f))
4194 {
4195 return qe_invalid;
4196 }
4197
4198
1/2
✓ Branch 0 taken 7918 times.
✗ Branch 1 not taken.
7918 if(s_version>3)
4199 {
4200
2/4
✓ Branch 0 taken 7918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7918 times.
✗ Branch 3 not taken.
7918 if(!p_igetw(&tempMsgString.listpos,f))
4201 {
4202 return qe_invalid;
4203 }
4204 7918 }
4205 }
4206
4207
1/2
✓ Branch 0 taken 27019 times.
✗ Branch 1 not taken.
27019 MsgStrings[i].copyAll(tempMsgString);
4208 27019 }
4209 }
4210
4211 123 msg_count=temp_msg_count;
4212
4213 123 return 0;
4214 123 }
4215
4216 123 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4217 {
4218
2/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
123 if((Header->zelda_version < 0x192)||
4219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4220 {
4221 4 return 0;
4222 }
4223
4224 119 word temp_door_combo_set_count=0;
4225 DoorComboSet tempDoorComboSet;
4226 word dummy_word;
4227 int32_t dummy_long;
4228 byte padding;
4229 119 int32_t s_version = 0;
4230
4231
2/2
✓ Branch 0 taken 30464 times.
✓ Branch 1 taken 119 times.
30583 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4232 {
4233 30464 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4234 30464 }
4235
4236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(Header->zelda_version > 0x192)
4237 {
4238 //section version info
4239
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&s_version,f))
4240 {
4241 return qe_invalid;
4242 }
4243
4244 119 FFCore.quest_format[vDoors] = s_version;
4245
4246 //al_trace("Door combo sets version %d\n", dummy_word);
4247
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&dummy_word,f))
4248 {
4249 return qe_invalid;
4250 }
4251
4252 //section size
4253
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetl(&dummy_long,f))
4254 {
4255 return qe_invalid;
4256 }
4257 119 }
4258
4259 //finally... section data
4260
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&temp_door_combo_set_count,f))
4261 {
4262 return qe_invalid;
4263 }
4264
4265
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
119 if (!(temp_door_combo_set_count >= 0 && temp_door_combo_set_count <= MAXDOORCOMBOSETS))
4266 {
4267 return qe_invalid;
4268 }
4269
4270
2/2
✓ Branch 0 taken 959 times.
✓ Branch 1 taken 119 times.
1078 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4271 {
4272 959 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4273
4274 //name
4275
1/2
✓ Branch 0 taken 959 times.
✗ Branch 1 not taken.
959 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f))
4276 {
4277 return qe_invalid;
4278 }
4279
4280
1/2
✓ Branch 0 taken 959 times.
✗ Branch 1 not taken.
959 if(Header->zelda_version < 0x193)
4281 {
4282 if(!p_getc(&padding,f))
4283 {
4284 return qe_invalid;
4285 }
4286 }
4287
4288 //up door
4289
2/2
✓ Branch 0 taken 8631 times.
✓ Branch 1 taken 959 times.
9590 for(int32_t j=0; j<9; j++)
4290 {
4291
2/2
✓ Branch 0 taken 34524 times.
✓ Branch 1 taken 8631 times.
43155 for(int32_t k=0; k<4; k++)
4292 {
4293
1/2
✓ Branch 0 taken 34524 times.
✗ Branch 1 not taken.
34524 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4294 {
4295 return qe_invalid;
4296 }
4297 34524 }
4298 8631 }
4299
4300
2/2
✓ Branch 0 taken 8631 times.
✓ Branch 1 taken 959 times.
9590 for(int32_t j=0; j<9; j++)
4301 {
4302
2/2
✓ Branch 0 taken 34524 times.
✓ Branch 1 taken 8631 times.
43155 for(int32_t k=0; k<4; k++)
4303 {
4304
1/2
✓ Branch 0 taken 34524 times.
✗ Branch 1 not taken.
34524 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4305 {
4306 return qe_invalid;
4307 }
4308 34524 }
4309 8631 }
4310
4311 //down door
4312
2/2
✓ Branch 0 taken 8631 times.
✓ Branch 1 taken 959 times.
9590 for(int32_t j=0; j<9; j++)
4313 {
4314
2/2
✓ Branch 0 taken 34524 times.
✓ Branch 1 taken 8631 times.
43155 for(int32_t k=0; k<4; k++)
4315 {
4316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34524 times.
34524 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4317 {
4318 return qe_invalid;
4319 }
4320 34524 }
4321 8631 }
4322
4323
2/2
✓ Branch 0 taken 8631 times.
✓ Branch 1 taken 959 times.
9590 for(int32_t j=0; j<9; j++)
4324 {
4325
2/2
✓ Branch 0 taken 34524 times.
✓ Branch 1 taken 8631 times.
43155 for(int32_t k=0; k<4; k++)
4326 {
4327
1/2
✓ Branch 0 taken 34524 times.
✗ Branch 1 not taken.
34524 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4328 {
4329 return qe_invalid;
4330 }
4331 34524 }
4332 8631 }
4333
4334 //left door
4335
2/2
✓ Branch 0 taken 8631 times.
✓ Branch 1 taken 959 times.
9590 for(int32_t j=0; j<9; j++)
4336 {
4337
2/2
✓ Branch 0 taken 51786 times.
✓ Branch 1 taken 8631 times.
60417 for(int32_t k=0; k<6; k++)
4338 {
4339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51786 times.
51786 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4340 {
4341 return qe_invalid;
4342 }
4343 51786 }
4344 8631 }
4345
4346
2/2
✓ Branch 0 taken 8631 times.
✓ Branch 1 taken 959 times.
9590 for(int32_t j=0; j<9; j++)
4347 {
4348
2/2
✓ Branch 0 taken 51786 times.
✓ Branch 1 taken 8631 times.
60417 for(int32_t k=0; k<6; k++)
4349 {
4350
1/2
✓ Branch 0 taken 51786 times.
✗ Branch 1 not taken.
51786 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4351 {
4352 return qe_invalid;
4353 }
4354 51786 }
4355 8631 }
4356
4357 //right door
4358
2/2
✓ Branch 0 taken 8631 times.
✓ Branch 1 taken 959 times.
9590 for(int32_t j=0; j<9; j++)
4359 {
4360
2/2
✓ Branch 0 taken 51786 times.
✓ Branch 1 taken 8631 times.
60417 for(int32_t k=0; k<6; k++)
4361 {
4362
1/2
✓ Branch 0 taken 51786 times.
✗ Branch 1 not taken.
51786 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4363 {
4364 return qe_invalid;
4365 }
4366 51786 }
4367 8631 }
4368
4369
2/2
✓ Branch 0 taken 8631 times.
✓ Branch 1 taken 959 times.
9590 for(int32_t j=0; j<9; j++)
4370 {
4371
2/2
✓ Branch 0 taken 51786 times.
✓ Branch 1 taken 8631 times.
60417 for(int32_t k=0; k<6; k++)
4372 {
4373
1/2
✓ Branch 0 taken 51786 times.
✗ Branch 1 not taken.
51786 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4374 {
4375 return qe_invalid;
4376 }
4377 51786 }
4378 8631 }
4379
4380 //up bomb rubble
4381
2/2
✓ Branch 0 taken 1918 times.
✓ Branch 1 taken 959 times.
2877 for(int32_t j=0; j<2; j++)
4382 {
4383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1918 times.
1918 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4384 {
4385 return qe_invalid;
4386 }
4387 1918 }
4388
4389
2/2
✓ Branch 0 taken 1918 times.
✓ Branch 1 taken 959 times.
2877 for(int32_t j=0; j<2; j++)
4390 {
4391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1918 times.
1918 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4392 {
4393 return qe_invalid;
4394 }
4395 1918 }
4396
4397 //down bomb rubble
4398
2/2
✓ Branch 0 taken 1918 times.
✓ Branch 1 taken 959 times.
2877 for(int32_t j=0; j<2; j++)
4399 {
4400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1918 times.
1918 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4401 {
4402 return qe_invalid;
4403 }
4404 1918 }
4405
4406
2/2
✓ Branch 0 taken 1918 times.
✓ Branch 1 taken 959 times.
2877 for(int32_t j=0; j<2; j++)
4407 {
4408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1918 times.
1918 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4409 {
4410 return qe_invalid;
4411 }
4412 1918 }
4413
4414 //left bomb rubble
4415
2/2
✓ Branch 0 taken 2877 times.
✓ Branch 1 taken 959 times.
3836 for(int32_t j=0; j<3; j++)
4416 {
4417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2877 times.
2877 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4418 {
4419 return qe_invalid;
4420 }
4421 2877 }
4422
4423
2/2
✓ Branch 0 taken 2877 times.
✓ Branch 1 taken 959 times.
3836 for(int32_t j=0; j<3; j++)
4424 {
4425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2877 times.
2877 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4426 {
4427 return qe_invalid;
4428 }
4429 2877 }
4430
4431
1/2
✓ Branch 0 taken 959 times.
✗ Branch 1 not taken.
959 if(Header->zelda_version < 0x193)
4432 {
4433 if(!p_getc(&padding,f))
4434 {
4435 return qe_invalid;
4436 }
4437
4438 }
4439
4440 //right bomb rubble
4441
2/2
✓ Branch 0 taken 2877 times.
✓ Branch 1 taken 959 times.
3836 for(int32_t j=0; j<3; j++)
4442 {
4443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2877 times.
2877 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4444 {
4445 return qe_invalid;
4446 }
4447 2877 }
4448
4449
2/2
✓ Branch 0 taken 2877 times.
✓ Branch 1 taken 959 times.
3836 for(int32_t j=0; j<3; j++)
4450 {
4451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2877 times.
2877 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4452 {
4453 return qe_invalid;
4454 }
4455 2877 }
4456
4457
1/2
✓ Branch 0 taken 959 times.
✗ Branch 1 not taken.
959 if(Header->zelda_version < 0x193)
4458 {
4459 if(!p_getc(&padding,f))
4460 {
4461 return qe_invalid;
4462 }
4463 }
4464
4465 //walkthrough stuff
4466
2/2
✓ Branch 0 taken 3836 times.
✓ Branch 1 taken 959 times.
4795 for(int32_t j=0; j<4; j++)
4467 {
4468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3836 times.
3836 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4469 {
4470 return qe_invalid;
4471 }
4472 3836 }
4473
4474
2/2
✓ Branch 0 taken 3836 times.
✓ Branch 1 taken 959 times.
4795 for(int32_t j=0; j<4; j++)
4475 {
4476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3836 times.
3836 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4477 {
4478 return qe_invalid;
4479 }
4480 3836 }
4481
4482 //flags
4483
2/2
✓ Branch 0 taken 1918 times.
✓ Branch 1 taken 959 times.
2877 for(int32_t j=0; j<2; j++)
4484 {
4485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1918 times.
1918 if(!p_getc(&tempDoorComboSet.flags[j],f))
4486 {
4487 return qe_invalid;
4488 }
4489 1918 }
4490
4491
1/2
✓ Branch 0 taken 959 times.
✗ Branch 1 not taken.
959 if(Header->zelda_version < 0x193)
4492 {
4493 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4494 {
4495 return qe_invalid;
4496 }
4497 }
4498
4499 959 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4500 959 }
4501
4502 119 door_combo_set_count=temp_door_combo_set_count;
4503
4504 119 return 0;
4505 123 }
4506
4507 int32_t count_dmaps()
4508 {
4509 int32_t i=MAXDMAPS-1;
4510 bool found=false;
4511
4512 while(i>=0 && !found)
4513 {
4514 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4515 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4516 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4517 found=true;
4518
4519 for(int32_t j=0; j<8; j++)
4520 {
4521 if(DMaps[i].grid[j]!=0)
4522
4523 found=true;
4524 }
4525
4526 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4527 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4528 found=true;
4529
4530 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4531 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4532 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4533 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4534 found=true;
4535
4536 if(!found)
4537 {
4538 i--;
4539 }
4540 }
4541
4542 return i+1;
4543 }
4544
4545
4546 int32_t count_shops(miscQdata *Misc)
4547 {
4548 int32_t i=NUM_SHOPS-1,j;
4549 bool found=false;
4550
4551 while(i>=0 && !found)
4552 {
4553 j=2;
4554
4555 while(j>=0 && !found)
4556 {
4557 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4558 {
4559 found=true;
4560 }
4561 else
4562 {
4563 j--;
4564 }
4565 }
4566
4567 if(Misc->shop[i].name[0]!=0)
4568 {
4569 found=true;
4570 }
4571
4572 if(!found)
4573 {
4574 i--;
4575 }
4576 }
4577
4578 return i+1;
4579 }
4580
4581 int32_t count_infos(miscQdata *Misc)
4582 {
4583 int32_t i=255,j;
4584 bool found=false;
4585
4586 while(i>=0 && !found)
4587 {
4588 j=2;
4589
4590 while(j>=0 && !found)
4591 {
4592 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4593 {
4594 found=true;
4595 }
4596 else
4597 {
4598 j--;
4599 }
4600 }
4601
4602 if(Misc->info[i].name[0]!=0)
4603 {
4604 found=true;
4605 }
4606
4607 if(!found)
4608 {
4609 i--;
4610 }
4611 }
4612
4613 return i+1;
4614 }
4615
4616 int32_t count_warprings(miscQdata *Misc)
4617 {
4618 int32_t i=15,j;
4619 bool found=false;
4620
4621 while(i>=0 && !found)
4622 {
4623 j=7;
4624
4625 while(j>=0 && !found)
4626 {
4627 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4628 {
4629 found=true;
4630 }
4631 else
4632 {
4633 j--;
4634 }
4635 }
4636
4637 if(!found)
4638 {
4639 i--;
4640 }
4641 }
4642
4643 return i+1;
4644 }
4645
4646 int32_t count_palcycles(miscQdata *Misc)
4647 {
4648 int32_t i=255,j;
4649 bool found=false;
4650
4651 while(i>=0 && !found)
4652 {
4653 j=2;
4654
4655 while(j>=0 && !found)
4656 {
4657 if(Misc->cycles[i][j].count!=0)
4658 {
4659 found=true;
4660 }
4661 else
4662 {
4663 j--;
4664 }
4665 }
4666
4667 if(!found)
4668 {
4669 i--;
4670 }
4671 }
4672
4673 return i+1;
4674 }
4675
4676 263075 void clear_screen(mapscr *temp_scr)
4677 {
4678 263075 temp_scr->zero_memory();
4679 263075 }
4680
4681 123 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4682 {
4683 123 word dmapstoread=0;
4684 dmap tempDMap;
4685
4686 int32_t dummy;
4687 123 word s_version=0, s_cversion=0;
4688 byte padding;
4689
4690
2/2
✓ Branch 0 taken 62976 times.
✓ Branch 1 taken 123 times.
63099 for(int32_t i=0; i<max_dmaps; i++)
4691 {
4692 62976 memset(&DMaps[start_dmap+i],0,sizeof(dmap));
4693 62976 sprintf(DMaps[start_dmap+i].title," ");
4694 62976 sprintf(DMaps[start_dmap+i].intro," ");
4695 62976 DMaps[start_dmap+i].type |= dmCAVE;
4696 62976 }
4697
4698
3/4
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✓ Branch 3 taken 4 times.
123 if(!Header || Header->zelda_version > 0x192)
4699 {
4700 //section version info
4701
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&s_version,f))
4702 {
4703 return qe_invalid;
4704 }
4705
4706 119 FFCore.quest_format[vDMaps] = s_version;
4707
4708 //al_trace("DMaps version %d\n", s_version);
4709
4710
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&s_cversion,f))
4711 {
4712 return qe_invalid;
4713 }
4714
4715 //section size
4716
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetl(&dummy,f))
4717 {
4718 return qe_invalid;
4719 }
4720
4721 //finally... section data
4722
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&dmapstoread,f))
4723 {
4724 return qe_invalid;
4725 }
4726 119 }
4727 else
4728 {
4729
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
4730 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4731 {
4732 4 dmapstoread=32;
4733 4 }
4734 else if(s_version <= 4)
4735 {
4736 dmapstoread=OLDMAXDMAPS;
4737 }
4738 else
4739 {
4740 dmapstoread=MAXDMAPS;
4741 }
4742 }
4743
4744
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 107 times.
123 dmapstoread=zc_min(dmapstoread, max_dmaps);
4745
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 107 times.
123 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4746
4747
2/2
✓ Branch 0 taken 57984 times.
✓ Branch 1 taken 123 times.
58107 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4748 {
4749 57984 memset(&tempDMap,0,sizeof(dmap));
4750 57984 sprintf(tempDMap.title," ");
4751 57984 sprintf(tempDMap.intro," ");
4752
4753
1/2
✓ Branch 0 taken 57984 times.
✗ Branch 1 not taken.
57984 if(!p_getc(&tempDMap.map,f))
4754 {
4755 return qe_invalid;
4756 }
4757
4758
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 54784 times.
57984 if(s_version <= 4)
4759 {
4760 byte tempbyte;
4761
4762
1/2
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
3200 if(!p_getc(&tempbyte,f))
4763 {
4764 return qe_invalid;
4765 }
4766
4767 3200 tempDMap.level=(word)tempbyte;
4768 3200 }
4769 else
4770 {
4771
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&tempDMap.level,f))
4772 {
4773 return qe_invalid;
4774 }
4775 }
4776
4777
1/2
✓ Branch 0 taken 57984 times.
✗ Branch 1 not taken.
57984 if(!p_getc(&tempDMap.xoff,f))
4778 {
4779 return qe_invalid;
4780 }
4781
4782
1/2
✓ Branch 0 taken 57984 times.
✗ Branch 1 not taken.
57984 if(!p_getc(&tempDMap.compass,f))
4783 {
4784 return qe_invalid;
4785 }
4786
4787
2/2
✓ Branch 0 taken 54784 times.
✓ Branch 1 taken 3200 times.
57984 if(s_version > 8) // February 2009
4788 {
4789
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&tempDMap.color,f))
4790 {
4791 return qe_invalid;
4792 }
4793 54784 }
4794 else
4795 {
4796 byte tempbyte;
4797
4798
1/2
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
3200 if(!p_getc(&tempbyte,f))
4799 {
4800 return qe_invalid;
4801 }
4802
4803 3200 tempDMap.color = (word)tempbyte;
4804 }
4805
4806
1/2
✓ Branch 0 taken 57984 times.
✗ Branch 1 not taken.
57984 if(!p_getc(&tempDMap.midi,f))
4807 {
4808 return qe_invalid;
4809 }
4810
4811
1/2
✓ Branch 0 taken 57984 times.
✗ Branch 1 not taken.
57984 if(!p_getc(&tempDMap.cont,f))
4812 {
4813 return qe_invalid;
4814 }
4815
4816
1/2
✓ Branch 0 taken 57984 times.
✗ Branch 1 not taken.
57984 if(!p_getc(&tempDMap.type,f))
4817 {
4818 return qe_invalid;
4819 }
4820
4821
4/4
✓ Branch 0 taken 818 times.
✓ Branch 1 taken 57166 times.
✓ Branch 2 taken 806 times.
✓ Branch 3 taken 12 times.
58802 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4822
1/2
✓ Branch 0 taken 818 times.
✗ Branch 1 not taken.
818 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4823 806 tempDMap.xoff = 0;
4824
4825
2/2
✓ Branch 0 taken 463872 times.
✓ Branch 1 taken 57984 times.
521856 for(int32_t j=0; j<8; j++)
4826 {
4827
1/2
✓ Branch 0 taken 463872 times.
✗ Branch 1 not taken.
463872 if(!p_getc(&tempDMap.grid[j],f))
4828 {
4829 return qe_invalid;
4830 }
4831 463872 }
4832
4833
4/8
✓ Branch 0 taken 57984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57856 times.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 57856 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
57984 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4834 {
4835
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
128 if(tempDMap.level>0&&tempDMap.level<10)
4836 {
4837 38 sprintf(tempDMap.title,"LEVEL-%d ", tempDMap.level);
4838 38 }
4839
4840
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
128 if(i==0 && Header->zelda_version <= 0x190)
4841 {
4842 4 tempDMap.cont-=tempDMap.xoff;
4843 4 tempDMap.compass-=tempDMap.xoff;
4844 4 }
4845
4846 //forgotten -DD
4847
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
128 if(tempDMap.level==0)
4848 {
4849 90 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4850 90 }
4851 128 }
4852 else
4853 {
4854
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f))
4855 {
4856 return qe_invalid;
4857 }
4858
4859
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!pfread(&tempDMap.title,sizeof(DMaps[0].title),f))
4860 {
4861 return qe_invalid;
4862 }
4863
4864
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f))
4865 {
4866 return qe_invalid;
4867 }
4868
4869
3/8
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57856 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 57856 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
57856 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4870 {
4871 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4872 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
4873
4874 continue;
4875 }
4876
4877
2/4
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57856 times.
✗ Branch 3 not taken.
57856 if(Header && (Header->zelda_version < 0x193))
4878 {
4879 if(!p_getc(&padding,f))
4880 {
4881 return qe_invalid;
4882 }
4883 }
4884
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 42496 times.
57856 if ( s_version >= 11 )
4885 {
4886
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&tempDMap.minimap_1_tile,f))
4887 {
4888 return qe_invalid;
4889 }
4890 15360 }
4891 else
4892 {
4893
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.minimap_1_tile,f))
4894 {
4895 return qe_invalid;
4896 }
4897 }
4898
4899
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&tempDMap.minimap_1_cset,f))
4900 {
4901 return qe_invalid;
4902 }
4903
4904
2/4
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57856 times.
✗ Branch 3 not taken.
57856 if(Header && (Header->zelda_version < 0x193))
4905 {
4906 if(!p_getc(&padding,f))
4907 {
4908 return qe_invalid;
4909 }
4910 }
4911
4912
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 42496 times.
57856 if ( s_version >= 11 )
4913 {
4914
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&tempDMap.minimap_2_tile,f))
4915 {
4916 return qe_invalid;
4917 }
4918 15360 }
4919 else
4920 {
4921
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.minimap_2_tile,f))
4922 {
4923 return qe_invalid;
4924 }
4925 }
4926
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&tempDMap.minimap_2_cset,f))
4927 {
4928 return qe_invalid;
4929 }
4930
4931
2/4
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57856 times.
✗ Branch 3 not taken.
57856 if(Header && (Header->zelda_version < 0x193))
4932 {
4933 if(!p_getc(&padding,f))
4934 {
4935 return qe_invalid;
4936 }
4937 }
4938
4939
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 42496 times.
57856 if ( s_version >= 11 )
4940 {
4941
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&tempDMap.largemap_1_tile,f))
4942 {
4943 return qe_invalid;
4944 }
4945 15360 }
4946 else
4947 {
4948
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.largemap_1_tile,f))
4949 {
4950 return qe_invalid;
4951 }
4952 }
4953
4954
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&tempDMap.largemap_1_cset,f))
4955 {
4956 return qe_invalid;
4957 }
4958
4959
2/4
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57856 times.
✗ Branch 3 not taken.
57856 if(Header && (Header->zelda_version < 0x193))
4960 {
4961
4962 if(!p_getc(&padding,f))
4963 {
4964 return qe_invalid;
4965 }
4966 }
4967
4968
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 42496 times.
57856 if ( s_version >= 11 )
4969 {
4970
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&tempDMap.largemap_2_tile,f))
4971 {
4972 return qe_invalid;
4973 }
4974 15360 }
4975 else
4976 {
4977
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.largemap_2_tile,f))
4978 {
4979 return qe_invalid;
4980 }
4981 }
4982
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&tempDMap.largemap_2_cset,f))
4983 {
4984 return qe_invalid;
4985 }
4986
4987
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f))
4988 {
4989 return qe_invalid;
4990 }
4991 }
4992
4993
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 54784 times.
57984 if(s_version>1)
4994 {
4995
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_getc(&tempDMap.tmusictrack,f))
4996 {
4997 return qe_invalid;
4998 }
4999
5000
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_getc(&tempDMap.active_subscreen,f))
5001 {
5002 return qe_invalid;
5003 }
5004
5005
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_getc(&tempDMap.passive_subscreen,f))
5006 {
5007 return qe_invalid;
5008 }
5009 54784 }
5010
5011
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 54784 times.
57984 if(s_version>2)
5012 {
5013 byte di[32];
5014
5015
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!pfread(&di, 32, f)) return qe_invalid;
5016
5017
2/2
✓ Branch 0 taken 14024704 times.
✓ Branch 1 taken 54784 times.
14079488 for(int32_t j=0; j<MAXITEMS; j++)
5018 {
5019
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 14024697 times.
14024704 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
5020 14024697 else tempDMap.disableditems[j]=0;
5021 14024704 }
5022 54784 }
5023
5024
2/2
✓ Branch 0 taken 54784 times.
✓ Branch 1 taken 3200 times.
57984 if(s_version >= 6)
5025 {
5026
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetl(&tempDMap.flags,f))
5027 {
5028 return qe_invalid;
5029 }
5030 54784 }
5031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3200 times.
3200 else if(s_version>3)
5032 {
5033 char temp;
5034
5035 if(!p_getc(&temp,f))
5036 {
5037 return qe_invalid;
5038 }
5039
5040 tempDMap.flags = temp;
5041 }
5042
3/8
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 816 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3200 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
5043 {
5044 816 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
5045 816 }
5046 else
5047 2384 tempDMap.flags=0;
5048
5049
2/2
✓ Branch 0 taken 54784 times.
✓ Branch 1 taken 3200 times.
57984 if(s_version<7)
5050 {
5051
3/4
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✓ Branch 2 taken 816 times.
✗ Branch 3 not taken.
3200 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
5052 816 tempDMap.flags|= dmfVIEWMAP;
5053 3200 }
5054
5055
2/2
✓ Branch 0 taken 54784 times.
✓ Branch 1 taken 3200 times.
57984 if(s_version<8)
5056 {
5057
4/4
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✓ Branch 2 taken 207 times.
✓ Branch 3 taken 609 times.
3200 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
5058 {
5059 609 tempDMap.type &= ~dmDNGN;
5060 609 tempDMap.type |= dmCAVE;
5061 609 }
5062
2/2
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 1736 times.
2591 else if((tempDMap.type&dmfTYPE)==dmCAVE)
5063 {
5064 1736 tempDMap.flags |= dmfMINIMAPCOLORFIX;
5065 1736 }
5066 3200 }
5067
5068
5/8
✓ Branch 0 taken 57984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 57856 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128 times.
✓ Branch 6 taken 57856 times.
✗ Branch 7 not taken.
57984 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
5069 57856 && (Header->zelda_version < 0x193))
5070 {
5071 if(!p_getc(&padding,f))
5072 {
5073 return qe_invalid;
5074 }
5075 }
5076
5077
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 15360 times.
57984 if(s_version >= 10)
5078 {
5079
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_getc(&tempDMap.sideview,f))
5080 {
5081 return qe_invalid;
5082 }
5083 15360 }
5084
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 42624 times.
57984 if(s_version < 10) tempDMap.sideview = 0;
5085
5086 //Dmap Scripts
5087
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 15360 times.
57984 if(s_version >= 12)
5088 {
5089
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetw(&tempDMap.script,f))
5090 {
5091 return qe_invalid;
5092 }
5093
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 15360 times.
138240 for ( int32_t q = 0; q < 8; q++ )
5094 {
5095
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if(!p_igetl(&tempDMap.initD[q],f))
5096 {
5097 return qe_invalid;
5098 }
5099 122880 }
5100 15360 }
5101
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 42624 times.
57984 if ( s_version < 12 )
5102 {
5103 42624 tempDMap.script = 0;
5104
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for ( int32_t q = 0; q < 8; q++ )
5105 {
5106 340992 tempDMap.initD[q] = 0;
5107 340992 }
5108 42624 }
5109
5110
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 15360 times.
57984 if(s_version >= 13)
5111 {
5112
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 15360 times.
138240 for ( int32_t q = 0; q < 8; q++ )
5113 {
5114
2/2
✓ Branch 0 taken 7987200 times.
✓ Branch 1 taken 122880 times.
8110080 for ( int32_t w = 0; w < 65; w++ )
5115 {
5116
1/2
✓ Branch 0 taken 7987200 times.
✗ Branch 1 not taken.
7987200 if(!p_getc(&tempDMap.initD_label[q][w],f))
5117 {
5118 return qe_invalid;
5119 }
5120 7987200 }
5121 122880 }
5122 15360 }
5123
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 42624 times.
57984 if ( s_version < 13 )
5124 {
5125 42624 tempDMap.script = 0;
5126
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for ( int32_t q = 0; q < 8; q++ )
5127 {
5128
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for ( int32_t w = 0; w < 65; w++ )
5129 22164480 tempDMap.initD_label[q][w] = 0;
5130 340992 }
5131 42624 }
5132
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 42624 times.
57984 if(s_version >= 14)
5133 {
5134
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetw(&tempDMap.active_sub_script,f))
5135 {
5136 return qe_invalid;
5137 }
5138
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetw(&tempDMap.passive_sub_script,f))
5139 {
5140 return qe_invalid;
5141 }
5142
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 15360 times.
138240 for ( int32_t q = 0; q < 8; ++q )
5143 {
5144
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if(!p_igetl(&tempDMap.sub_initD[q],f))
5145 {
5146 return qe_invalid;
5147 }
5148 122880 }
5149
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 15360 times.
138240 for(int32_t q = 0; q < 8; ++q)
5150 {
5151
2/2
✓ Branch 0 taken 7987200 times.
✓ Branch 1 taken 122880 times.
8110080 for ( int32_t w = 0; w < 65; ++w )
5152 {
5153
1/2
✓ Branch 0 taken 7987200 times.
✗ Branch 1 not taken.
7987200 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
5154 {
5155 return qe_invalid;
5156 }
5157 7987200 }
5158 122880 }
5159 15360 }
5160 else
5161 {
5162 42624 tempDMap.active_sub_script = 0;
5163 42624 tempDMap.passive_sub_script = 0;
5164
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for(int32_t q = 0; q < 8; ++q)
5165 {
5166 340992 tempDMap.sub_initD[q] = 0;
5167
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for(int32_t w = 0; w < 65; ++w)
5168 22164480 tempDMap.sub_initD_label[q][w] = 0;
5169 340992 }
5170 }
5171
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 42624 times.
57984 if(s_version >= 15)
5172 {
5173
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetw(&tempDMap.onmap_script,f))
5174 {
5175 return qe_invalid;
5176 }
5177
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 15360 times.
138240 for ( int32_t q = 0; q < 8; ++q )
5178 {
5179
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if(!p_igetl(&tempDMap.onmap_initD[q],f))
5180 {
5181 return qe_invalid;
5182 }
5183 122880 }
5184
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 15360 times.
138240 for(int32_t q = 0; q < 8; ++q)
5185 {
5186
2/2
✓ Branch 0 taken 7987200 times.
✓ Branch 1 taken 122880 times.
8110080 for ( int32_t w = 0; w < 65; ++w )
5187 {
5188
1/2
✓ Branch 0 taken 7987200 times.
✗ Branch 1 not taken.
7987200 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
5189 {
5190 return qe_invalid;
5191 }
5192 7987200 }
5193 122880 }
5194 15360 }
5195 else
5196 {
5197 42624 tempDMap.onmap_script = 0;
5198
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for(int32_t q = 0; q < 8; ++q)
5199 {
5200 340992 tempDMap.onmap_initD[q] = 0;
5201
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for(int32_t w = 0; w < 65; ++w)
5202 {
5203 22164480 tempDMap.onmap_initD_label[q][w] = 0;
5204 22164480 }
5205 340992 }
5206 }
5207
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 42624 times.
57984 if(s_version >= 16)
5208 {
5209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15360 times.
15360 if(!p_igetw(&tempDMap.mirrorDMap,f))
5210 {
5211 return qe_invalid;
5212 }
5213 15360 }
5214 else
5215 {
5216 42624 tempDMap.mirrorDMap = -1;
5217 }
5218
5219
1/2
✓ Branch 0 taken 57984 times.
✗ Branch 1 not taken.
57984 if(s_version >= 17)
5220 {
5221 // Reserved for z3.
5222 }
5223
5224 57984 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
5225 57984 }
5226
5227 123 return 0;
5228 123 }
5229
5230 107 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5231 {
5232 //these are here to bypass compiler warnings about unused arguments
5233 107 Header=Header;
5234
5235 miscQdata temp_misc;
5236 107 word s_version=0, s_cversion=0;
5237 107 int32_t tempsize=0;
5238 word dummyw;
5239
5240 107 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5241
5242 //section version info
5243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(!p_igetw(&s_version,f))
5244 {
5245 return qe_invalid;
5246 }
5247
5248 107 FFCore.quest_format[vColours] = s_version;
5249
5250 107 al_trace("Misc Colours section version: %d\n", s_version);
5251
5252 //al_trace("Misc. colors version %d\n", s_version);
5253
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetw(&s_cversion,f))
5254 {
5255 return qe_invalid;
5256 }
5257
5258
5259 //section size
5260
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetl(&tempsize,f))
5261 {
5262 return qe_invalid;
5263 }
5264
5265 //finally... section data
5266 107 readsize=0;
5267
5268
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.text,f))
5269 {
5270 return qe_invalid;
5271 }
5272
5273
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.caption,f))
5274 {
5275 return qe_invalid;
5276 }
5277
5278
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.overw_bg,f))
5279 {
5280 return qe_invalid;
5281 }
5282
5283
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5284 {
5285 return qe_invalid;
5286 }
5287
5288
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5289 {
5290 return qe_invalid;
5291 }
5292
5293
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.cave_fg,f))
5294 {
5295 return qe_invalid;
5296 }
5297
5298
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.bs_dk,f))
5299 {
5300 return qe_invalid;
5301 }
5302
5303
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.bs_goal,f))
5304 {
5305 return qe_invalid;
5306 }
5307
5308
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.compass_lt,f))
5309 {
5310 return qe_invalid;
5311 }
5312
5313
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.compass_dk,f))
5314 {
5315 return qe_invalid;
5316 }
5317
5318
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5319 {
5320 return qe_invalid;
5321 }
5322
5323
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.triframe_color,f))
5324 {
5325 return qe_invalid;
5326 }
5327
5328
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.hero_dot,f))
5329 {
5330 return qe_invalid;
5331 }
5332
5333
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5334 {
5335 return qe_invalid;
5336 }
5337
5338
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5339 {
5340 return qe_invalid;
5341 }
5342
5343
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5344 {
5345 return qe_invalid;
5346 }
5347
5348
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5349 {
5350 return qe_invalid;
5351 }
5352
5353
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5354 {
5355 return qe_invalid;
5356 }
5357
5358
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5359 {
5360 return qe_invalid;
5361 }
5362
5363
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5364 {
5365 return qe_invalid;
5366 }
5367
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 77 times.
107 if(s_version < 4)
5368 {
5369
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5370 return qe_invalid;
5371 77 temp_misc.colors.triforce_tile = dummyw;
5372
5373
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5374 return qe_invalid;
5375 77 temp_misc.colors.triframe_tile = dummyw;
5376
5377
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5378 return qe_invalid;
5379 77 temp_misc.colors.overworld_map_tile = dummyw;
5380
5381
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5382 return qe_invalid;
5383 77 temp_misc.colors.dungeon_map_tile = dummyw;
5384
5385
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5386 return qe_invalid;
5387 77 temp_misc.colors.blueframe_tile = dummyw;
5388
5389
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5390 return qe_invalid;
5391 77 temp_misc.colors.HCpieces_tile = dummyw;
5392 77 }
5393
5394
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5395 {
5396 return qe_invalid;
5397 }
5398
5399
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5400 {
5401 return qe_invalid;
5402 }
5403
5404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(s_version < 2)
5405 {
5406 temp_misc.colors.msgtext = 0x01;
5407 }
5408 else
5409 {
5410
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&temp_misc.colors.msgtext, f))
5411 {
5412 return qe_invalid;
5413 }
5414 }
5415
5416
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 30 times.
107 if ( s_version >= 3 ) //expanded tile pages to 825
5417 {
5418
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5419 {
5420 return qe_invalid;
5421 }
5422
5423
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5424 {
5425 return qe_invalid;
5426 }
5427
5428
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5429 {
5430 return qe_invalid;
5431 }
5432
5433
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5434 {
5435 return qe_invalid;
5436 }
5437
5438
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5439 {
5440 return qe_invalid;
5441 }
5442
5443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5444 {
5445 return qe_invalid;
5446 }
5447 30 }
5448
5449 107 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5450
5451 107 return 0;
5452 107 }
5453
5454 107 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5455 {
5456 miscQdata temp_misc;
5457 107 word s_version=0, s_cversion=0;
5458 byte icons;
5459 107 int32_t tempsize=0;
5460
5461 107 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5462
5463 //section version info
5464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(!p_igetw(&s_version,f))
5465 {
5466 return qe_invalid;
5467 }
5468
5469 107 FFCore.quest_format[vIcons] = s_version;
5470
5471 //al_trace("Game icons version %d\n", s_version);
5472
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetw(&s_cversion,f))
5473 {
5474 return qe_invalid;
5475 }
5476
5477
5478 //section size
5479
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetl(&tempsize,f))
5480 {
5481 return qe_invalid;
5482 }
5483
5484 //finally... section data
5485 107 readsize=0;
5486
5487 107 icons=4;
5488
5489
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 77 times.
107 if ( s_version >= 10 )
5490 {
5491
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t i=0; i<icons; i++)
5492 {
5493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_igetl(&temp_misc.icons[i],f))
5494 {
5495 return qe_invalid;
5496 }
5497 120 }
5498 30 }
5499 else
5500 {
5501
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<icons; i++)
5502 {
5503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
308 if(!p_igetw(&temp_misc.icons[i],f))
5504 {
5505 return qe_invalid;
5506 }
5507 308 }
5508 }
5509
5510 107 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5511
5512 107 return 0;
5513 107 }
5514
5515 123 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5516 {
5517 123 word maxinfos=256;
5518 123 word maxshops=256;
5519 123 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5520 123 word ponds=16, pondsize=72, expansionsize=98*2;
5521 byte tempbyte, padding;
5522 miscQdata temp_misc;
5523 123 word s_version=0, s_cversion=0;
5524 word swaptmp;
5525 123 int32_t tempsize=0;
5526
5527 123 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5528
5529
2/2
✓ Branch 0 taken 31488 times.
✓ Branch 1 taken 123 times.
31611 for(int32_t i=0; i<maxshops; ++i)
5530 {
5531 31488 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5532 31488 }
5533
5534
2/2
✓ Branch 0 taken 31488 times.
✓ Branch 1 taken 123 times.
31611 for(int32_t i=0; i<maxinfos; ++i)
5535 {
5536 31488 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5537 31488 }
5538
5539
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 119 times.
123 if(Header->zelda_version > 0x192)
5540 {
5541 //section version info
5542
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&s_version,f))
5543 {
5544 return qe_invalid;
5545 }
5546
5547 119 FFCore.quest_format[vMisc] = s_version;
5548
5549 //al_trace("Misc. data version %d\n", s_version);
5550
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&s_cversion,f))
5551 {
5552 return qe_invalid;
5553 }
5554
5555
5556 //section size
5557
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetl(&tempsize,f))
5558 {
5559 return qe_invalid;
5560 }
5561 119 }
5562
5563 //finally... section data
5564 123 readsize=0;
5565
5566 //shops
5567
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 119 times.
123 if(Header->zelda_version > 0x192)
5568 {
5569
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&shops,f))
5570 {
5571 return qe_invalid;
5572 }
5573 119 }
5574
5575
2/4
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 123 times.
123 if (!(shops >= 0 && shops <= NUM_SHOPS))
5576 {
5577 return qe_invalid;
5578 }
5579
5580
2/2
✓ Branch 0 taken 1360 times.
✓ Branch 1 taken 123 times.
1483 for(int32_t i=0; i<shops; i++)
5581 {
5582
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1137 times.
1360 if(s_version > 6)
5583 {
5584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1137 times.
1137 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f))
5585 {
5586 return qe_invalid;
5587 }
5588 1137 }
5589
5590
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 1360 times.
5440 for(int32_t j=0; j<3; j++)
5591 {
5592
1/2
✓ Branch 0 taken 4080 times.
✗ Branch 1 not taken.
4080 if(!p_getc(&temp_misc.shop[i].item[j],f))
5593 {
5594 return qe_invalid;
5595 }
5596
5597
2/2
✓ Branch 0 taken 3411 times.
✓ Branch 1 taken 669 times.
4080 if(s_version < 4)
5598 {
5599 669 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5600 669 }
5601 4080 }
5602
5603
2/2
✓ Branch 0 taken 1296 times.
✓ Branch 1 taken 64 times.
1360 if(Header->zelda_version < 0x193)
5604 {
5605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(!p_getc(&tempbyte,f))
5606 {
5607 return qe_invalid;
5608 }
5609 64 }
5610
5611
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 1360 times.
5440 for(int32_t j=0; j<3; j++)
5612 {
5613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4080 times.
4080 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5614 {
5615 return qe_invalid;
5616 }
5617 4080 }
5618
5619
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1137 times.
1360 if(s_version > 3)
5620 {
5621
2/2
✓ Branch 0 taken 3411 times.
✓ Branch 1 taken 1137 times.
4548 for(int32_t j=0; j<3; j++)
5622 {
5623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3411 times.
3411 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5624 return qe_invalid;
5625 3411 }
5626 1137 }
5627
5628 /*
5629 if(s_version < 8)
5630 {
5631 for(int32_t j=0; j<3; j++)
5632 {
5633 (&temp_misc.shop[i].str[j])=0; //initialise.
5634 }
5635 }
5636 */
5637 1360 }
5638
5639 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5640
2/2
✓ Branch 0 taken 31488 times.
✓ Branch 1 taken 123 times.
31611 for(int32_t i=0; i<maxshops; ++i)
5641 {
5642
2/2
✓ Branch 0 taken 62976 times.
✓ Branch 1 taken 31488 times.
94464 for(int32_t j=0; j<3-1; j++)
5643 {
5644
2/2
✓ Branch 0 taken 62976 times.
✓ Branch 1 taken 91581 times.
154557 for(int32_t k=0; k<2-j; k++)
5645 {
5646 91581 if(temp_misc.shop[i].hasitem[k]==0)
5647 {
5648 91581 swaptmp = temp_misc.shop[i].item[k];
5649 91581 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5650 91581 temp_misc.shop[i].item[k+1] = swaptmp;
5651 91581 swaptmp = temp_misc.shop[i].price[k];
5652 91581 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5653 91581 temp_misc.shop[i].price[k+1] = swaptmp;
5654 91581 swaptmp = temp_misc.shop[i].hasitem[k];
5655 91581 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5656 91581 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5657 91581 }
5658 91581 }
5659 62976 }
5660 31488 }
5661
5662 //infos
5663
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 119 times.
123 if(Header->zelda_version > 0x192)
5664 {
5665
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&infos,f))
5666 {
5667 return qe_invalid;
5668 }
5669 119 }
5670
5671
2/4
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 123 times.
123 if (!(infos >= 0 && infos <= NUM_INFOS))
5672 {
5673 return qe_invalid;
5674 }
5675
5676
5677
2/2
✓ Branch 0 taken 1671 times.
✓ Branch 1 taken 123 times.
1794 for(int32_t i=0; i<infos; i++)
5678 {
5679
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 1571 times.
1671 if(s_version > 6)
5680 {
5681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1571 times.
1571 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f))
5682 {
5683 return qe_invalid;
5684 }
5685 1571 }
5686
5687
2/2
✓ Branch 0 taken 5013 times.
✓ Branch 1 taken 1671 times.
6684 for(int32_t j=0; j<3; j++)
5688 {
5689
2/4
✓ Branch 0 taken 4821 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5013 if((Header->zelda_version < 0x192)||
5690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4821 times.
4821 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5691 {
5692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5693 {
5694 return qe_invalid;
5695 }
5696
5697 192 temp_misc.info[i].str[j]=tempbyte;
5698 192 }
5699 else
5700 {
5701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4821 times.
4821 if(!p_igetw(&temp_misc.info[i].str[j],f))
5702 {
5703 return qe_invalid;
5704 }
5705 }
5706 5013 }
5707
5708
2/2
✓ Branch 0 taken 1607 times.
✓ Branch 1 taken 64 times.
1671 if(Header->zelda_version < 0x193)
5709 {
5710
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbyte,f))
5711 {
5712 return qe_invalid;
5713 }
5714 64 }
5715
5716
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1671 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1671 if((Header->zelda_version == 0x192)&&(Header->build>145))
5717 {
5718 if(!p_getc(&padding,f))
5719 {
5720 return qe_invalid;
5721 }
5722 }
5723
5724
2/2
✓ Branch 0 taken 5013 times.
✓ Branch 1 taken 1671 times.
6684 for(int32_t j=0; j<3; j++)
5725 {
5726
1/2
✓ Branch 0 taken 5013 times.
✗ Branch 1 not taken.
5013 if(!p_igetw(&temp_misc.info[i].price[j],f))
5727 {
5728 return qe_invalid;
5729 }
5730 5013 }
5731 1671 }
5732
5733 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5734
2/2
✓ Branch 0 taken 31488 times.
✓ Branch 1 taken 123 times.
31611 for(int32_t i=0; i<maxinfos; ++i)
5735 {
5736
2/2
✓ Branch 0 taken 62976 times.
✓ Branch 1 taken 31488 times.
94464 for(int32_t j=0; j<3-1; j++)
5737 {
5738
2/2
✓ Branch 0 taken 94464 times.
✓ Branch 1 taken 62976 times.
157440 for(int32_t k=0; k<2-j; k++)
5739 {
5740
2/2
✓ Branch 0 taken 1986 times.
✓ Branch 1 taken 92478 times.
94464 if(temp_misc.info[i].str[k]==0)
5741 {
5742 92478 swaptmp = temp_misc.info[i].str[k];
5743 92478 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5744 92478 temp_misc.info[i].str[k+1] = swaptmp;
5745 92478 swaptmp = temp_misc.info[i].price[k];
5746 92478 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5747 92478 temp_misc.info[i].price[k+1] = swaptmp;
5748 92478 }
5749 94464 }
5750 62976 }
5751 31488 }
5752
5753
5754 //warp rings
5755
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 107 times.
123 if(s_version > 5)
5756 107 warprings++;
5757
5758
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 119 times.
123 if(Header->zelda_version > 0x192)
5759 {
5760
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&warprings,f))
5761 {
5762 return qe_invalid;
5763 }
5764
5765
3/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 81 times.
✓ Branch 3 taken 38 times.
119 if (!(warprings >= 0 && warprings <= NUM_WARP_RINGS))
5766 {
5767 // return qe_invalid;
5768 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5769 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5770 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5771 38 }
5772 119 }
5773
5774
2/2
✓ Branch 0 taken 1244 times.
✓ Branch 1 taken 123 times.
1367 for(int32_t i=0; i<warprings; i++)
5775 {
5776 // See above comment on the `warprings` range check.
5777 1244 bool keepdata = i < NUM_WARP_RINGS;
5778
5779
2/2
✓ Branch 0 taken 10972 times.
✓ Branch 1 taken 1244 times.
12216 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5780 {
5781
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 9180 times.
10972 if(s_version <= 3)
5782 {
5783
1/2
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
1792 if(!p_getc(&tempbyte,f))
5784 {
5785 return qe_invalid;
5786 }
5787
5788
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 1120 times.
1792 if (keepdata)
5789 1120 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5790 1792 }
5791 else
5792 {
5793 word tempword;
5794
1/2
✓ Branch 0 taken 9180 times.
✗ Branch 1 not taken.
9180 if(!p_igetw(&tempword,f))
5795 {
5796 return qe_invalid;
5797 }
5798
5799
2/2
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 8667 times.
9180 if (keepdata)
5800 8667 temp_misc.warp[i].dmap[j] = tempword;
5801 }
5802 10972 }
5803
5804
2/2
✓ Branch 0 taken 10972 times.
✓ Branch 1 taken 1244 times.
12216 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5805 {
5806
1/2
✓ Branch 0 taken 10972 times.
✗ Branch 1 not taken.
10972 if(!p_getc(&tempbyte,f))
5807 {
5808 return qe_invalid;
5809 }
5810
2/2
✓ Branch 0 taken 1185 times.
✓ Branch 1 taken 9787 times.
10972 if (keepdata)
5811 9787 temp_misc.warp[i].scr[j] = tempbyte;
5812 10972 }
5813
5814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1244 times.
1244 if(!p_getc(&tempbyte,f))
5815 {
5816 return qe_invalid;
5817 }
5818
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1103 times.
1244 if (keepdata)
5819 1103 temp_misc.warp[i].size = tempbyte;
5820
5821
2/2
✓ Branch 0 taken 1212 times.
✓ Branch 1 taken 32 times.
1244 if(Header->zelda_version < 0x193)
5822 {
5823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&tempbyte,f))
5824 {
5825 return qe_invalid;
5826 }
5827 32 }
5828 1244 }
5829
5830 //palette cycles
5831
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
123 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5832 {
5833
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<256; i++)
5834 {
5835
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 1024 times.
4096 for(int32_t j=0; j<3; j++)
5836 {
5837 3072 temp_misc.cycles[i][j].first=0;
5838 3072 temp_misc.cycles[i][j].count=0;
5839 3072 temp_misc.cycles[i][j].speed=0;
5840 3072 }
5841 1024 }
5842
5843
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
5844 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5845 {
5846 4 palcycles=16;
5847 4 }
5848
5849
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4 times.
68 for(int32_t i=0; i<palcycles; i++)
5850 {
5851
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 64 times.
256 for(int32_t j=0; j<3; j++)
5852 {
5853
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5854 {
5855 return qe_invalid;
5856 }
5857
5858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5859 {
5860 return qe_invalid;
5861 }
5862
5863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5864 {
5865 return qe_invalid;
5866 }
5867 192 }
5868 64 }
5869 4 }
5870
5871 //Wind warps are now just another warp ring.
5872
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if(s_version <= 5)
5873 {
5874
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(Header->zelda_version > 0x192)
5875 {
5876
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&windwarps,f))
5877 {
5878 return qe_invalid;
5879 }
5880 12 }
5881
5882
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
16 if (!(windwarps >= 0 && windwarps <= NUM_WARP_RINGS))
5883 {
5884 return qe_invalid;
5885 }
5886
5887
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 16 times.
151 for(int32_t i=0; i<windwarps; i++)
5888 {
5889
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(s_version <= 3)
5890 {
5891
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!p_getc(&tempbyte,f))
5892 {
5893 return qe_invalid;
5894 }
5895
5896 135 temp_misc.warp[8].dmap[i]=tempbyte;
5897 135 }
5898 else
5899 {
5900 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5901 {
5902 return qe_invalid;
5903 }
5904 }
5905
5906
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5907 {
5908 return qe_invalid;
5909 }
5910
5911 135 temp_misc.warp[8].size = 9;
5912
5913
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(s_version == 5)
5914 {
5915 if(!p_getc(&tempbyte,f))
5916 {
5917 return qe_invalid;
5918 }
5919 }
5920 135 }
5921 16 }
5922
5923
5924 //triforce pieces
5925
2/2
✓ Branch 0 taken 984 times.
✓ Branch 1 taken 123 times.
1107 for(int32_t i=0; i<triforces; i++)
5926 {
5927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 984 times.
984 if(!p_getc(&temp_misc.triforce[i],f))
5928 {
5929 return qe_invalid;
5930 }
5931 984 }
5932
5933 //misc color data
5934
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if(s_version<3)
5935 {
5936
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.text,f))
5937 {
5938 return qe_invalid;
5939 }
5940
5941
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.caption,f))
5942 {
5943 return qe_invalid;
5944 }
5945
5946
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.overw_bg,f))
5947 {
5948 return qe_invalid;
5949 }
5950
5951
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5952 {
5953 return qe_invalid;
5954 }
5955
5956
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5957 {
5958 return qe_invalid;
5959 }
5960
5961
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.cave_fg,f))
5962 {
5963 return qe_invalid;
5964 }
5965
5966
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bs_dk,f))
5967 {
5968 return qe_invalid;
5969 }
5970
5971
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bs_goal,f))
5972 {
5973 return qe_invalid;
5974 }
5975
5976
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.compass_lt,f))
5977 {
5978 return qe_invalid;
5979 }
5980
5981
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.compass_dk,f))
5982 {
5983 return qe_invalid;
5984 }
5985
5986
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5987 {
5988 return qe_invalid;
5989 }
5990
5991
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triframe_color,f))
5992 {
5993 return qe_invalid;
5994 }
5995
5996
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.hero_dot,f))
5997 {
5998 return qe_invalid;
5999 }
6000
6001
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bmap_bg,f))
6002 {
6003 return qe_invalid;
6004 }
6005
6006
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bmap_fg,f))
6007 {
6008 return qe_invalid;
6009 }
6010
6011
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triforce_cset,f))
6012 {
6013 return qe_invalid;
6014 }
6015
6016
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triframe_cset,f))
6017 {
6018 return qe_invalid;
6019 }
6020
6021
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
6022 {
6023 return qe_invalid;
6024 }
6025
6026
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
6027 {
6028 return qe_invalid;
6029 }
6030
6031
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
6032 {
6033 return qe_invalid;
6034 }
6035
6036
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
6037 {
6038 return qe_invalid;
6039 }
6040
6041
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
6042 {
6043 return qe_invalid;
6044 }
6045
6046
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
6047 {
6048 return qe_invalid;
6049 }
6050
6051
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
6052 {
6053 return qe_invalid;
6054 }
6055
6056
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
6057 {
6058 return qe_invalid;
6059 }
6060
6061
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
6062 {
6063 return qe_invalid;
6064 }
6065
6066
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
6067 {
6068 return qe_invalid;
6069 }
6070
6071 16 temp_misc.colors.msgtext = 0x01;
6072
6073
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(Header->zelda_version < 0x193)
6074 {
6075
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4 times.
32 for(int32_t i=0; i<7; i++)
6076 {
6077
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&tempbyte,f))
6078 {
6079 return qe_invalid;
6080 }
6081 28 }
6082 4 }
6083
6084
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if((Header->zelda_version == 0x192)&&(Header->build>145))
6085 {
6086 for(int32_t i=0; i<256; i++)
6087 {
6088 if(!p_getc(&tempbyte,f))
6089 {
6090 return qe_invalid;
6091 }
6092 }
6093 }
6094
6095
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(s_version>1)
6096 {
6097 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
6098 {
6099 return qe_invalid;
6100 }
6101 }
6102
6103 //save game icons
6104
2/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if((Header->zelda_version < 0x192)||
6105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6106 {
6107 4 icons=3;
6108 4 }
6109
6110
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 16 times.
76 for(int32_t i=0; i<icons; i++)
6111 {
6112
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_igetw(&temp_misc.icons[i],f))
6113 {
6114 return qe_invalid;
6115 }
6116 60 }
6117 16 }
6118
6119
2/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
123 if((Header->zelda_version < 0x192)||
6120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6121 {
6122 4 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6123
6124 4 return 0;
6125 }
6126
6127 //pond information
6128
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(Header->zelda_version < 0x193)
6129 {
6130 if((Header->zelda_version == 0x192)&&(Header->build<146))
6131 {
6132 pondsize=25;
6133 }
6134
6135 for(int32_t i=0; i<ponds; i++)
6136 {
6137 for(int32_t j=0; j<pondsize; j++)
6138 {
6139 if(!p_getc(&tempbyte,f))
6140 {
6141 return qe_invalid;
6142
6143 }
6144 }
6145 }
6146 }
6147
6148 //end string
6149
1/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
119 if((Header->zelda_version < 0x192)||
6150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6151 {
6152 if(!p_getc(&tempbyte,f))
6153 {
6154 return qe_invalid;
6155 }
6156
6157 temp_misc.endstring=tempbyte;
6158
6159 if(!p_getc(&tempbyte,f))
6160 {
6161 return qe_invalid;
6162 }
6163 }
6164 else
6165 {
6166
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&temp_misc.endstring,f))
6167 {
6168 return qe_invalid;
6169 }
6170 }
6171
6172 //expansion
6173
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(Header->zelda_version < 0x193)
6174 {
6175 if((Header->zelda_version == 0x192)&&(Header->build<73))
6176 {
6177 expansionsize=99*2;
6178 }
6179
6180 for(int32_t i=0; i<expansionsize; i++)
6181 {
6182 if(!p_getc(&tempbyte,f))
6183 {
6184 return qe_invalid;
6185 }
6186 }
6187 }
6188 //shops v8
6189
6190
6191
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 30 times.
119 if(s_version >= 8)
6192 {
6193
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 30 times.
462 for(int32_t i=0; i<shops; i++)
6194 {
6195
2/2
✓ Branch 0 taken 1296 times.
✓ Branch 1 taken 432 times.
1728 for(int32_t j=0; j<3; j++)
6196 {
6197
1/2
✓ Branch 0 taken 1296 times.
✗ Branch 1 not taken.
1296 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6198 return qe_invalid;
6199 1296 }
6200 432 }
6201 30 }
6202
6203 119 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6204 119 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6205 119 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6206
6207 //v9 includes quest misc[32]
6208
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 30 times.
119 if(s_version >= 9)
6209 {
6210
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 30 times.
990 for ( int32_t q = 0; q < 32; q++ )
6211 {
6212
1/2
✓ Branch 0 taken 960 times.
✗ Branch 1 not taken.
960 if(!p_igetl(&temp_misc.questmisc[q],f))
6213 return qe_invalid;
6214 960 }
6215
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 30 times.
990 for ( int32_t q = 0; q < 32; q++ )
6216 {
6217
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 960 times.
123840 for ( int32_t j = 0; j < 128; j++ )
6218
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if(!p_getc(&temp_misc.questmisc_strings[q][j],f))
6219 return qe_invalid;
6220 960 }
6221 30 }
6222
6223
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 89 times.
119 if(s_version >= 11 )
6224 {
6225
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6226 return qe_invalid;
6227 30 }
6228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(s_version < 11 )
6229 {
6230 89 temp_misc.zscript_last_compiled_version = -1;
6231 89 }
6232
6233 119 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6234
6235
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 89 times.
119 if(s_version >= 12)
6236 {
6237 byte spr;
6238
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 30 times.
7710 for(int32_t q = 0; q < sprMAX; ++q)
6239 {
6240
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_getc(&spr,f))
6241 return qe_invalid;
6242 7680 temp_misc.sprites[q] = spr;
6243 7680 }
6244 30 }
6245 else
6246 {
6247 89 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6248 //temp_misc.sprites[sprFALL] = ;
6249 }
6250
6251
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 89 times.
119 if(s_version >= 13)
6252 {
6253
2/2
✓ Branch 0 taken 1920 times.
✓ Branch 1 taken 30 times.
1950 for(size_t q = 0; q < 64; ++q)
6254 {
6255 1920 bottletype* bt = &(temp_misc.bottle_types[q]);
6256
1/2
✓ Branch 0 taken 1920 times.
✗ Branch 1 not taken.
1920 if (!pfread(bt->name, 32, f))
6257 return qe_invalid;
6258
2/2
✓ Branch 0 taken 5760 times.
✓ Branch 1 taken 1920 times.
7680 for(size_t j = 0; j < 3; ++j)
6259 {
6260
1/2
✓ Branch 0 taken 5760 times.
✗ Branch 1 not taken.
5760 if (!p_getc(&(bt->counter[j]), f))
6261 return qe_invalid;
6262
1/2
✓ Branch 0 taken 5760 times.
✗ Branch 1 not taken.
5760 if (!p_igetw(&(bt->amount[j]), f))
6263 return qe_invalid;
6264 5760 }
6265
1/2
✓ Branch 0 taken 1920 times.
✗ Branch 1 not taken.
1920 if (!p_getc(&(bt->flags), f))
6266 return qe_invalid;
6267
1/2
✓ Branch 0 taken 1920 times.
✗ Branch 1 not taken.
1920 if (!p_getc(&(bt->next_type), f))
6268 return qe_invalid;
6269 1920 }
6270
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 30 times.
7710 for(size_t q = 0; q < 256; ++q)
6271 {
6272 7680 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6273
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if (!pfread(bst->name, 32, f))
6274 return qe_invalid;
6275
2/2
✓ Branch 0 taken 23040 times.
✓ Branch 1 taken 7680 times.
30720 for(size_t j = 0; j < 3; ++j)
6276 {
6277
1/2
✓ Branch 0 taken 23040 times.
✗ Branch 1 not taken.
23040 if (!p_getc(&(bst->fill[j]), f))
6278 return qe_invalid;
6279
1/2
✓ Branch 0 taken 23040 times.
✗ Branch 1 not taken.
23040 if (!p_igetw(&(bst->comb[j]), f))
6280 return qe_invalid;
6281
1/2
✓ Branch 0 taken 23040 times.
✗ Branch 1 not taken.
23040 if (!p_getc(&(bst->cset[j]), f))
6282 return qe_invalid;
6283
1/2
✓ Branch 0 taken 23040 times.
✗ Branch 1 not taken.
23040 if (!p_igetw(&(bst->price[j]), f))
6284 return qe_invalid;
6285
1/2
✓ Branch 0 taken 23040 times.
✗ Branch 1 not taken.
23040 if (!p_igetw(&(bst->str[j]), f))
6286 return qe_invalid;
6287 23040 }
6288 7680 }
6289 30 }
6290 else
6291 {
6292
2/2
✓ Branch 0 taken 5696 times.
✓ Branch 1 taken 89 times.
5785 for(size_t q = 0; q < 64; ++q)
6293 5696 temp_misc.bottle_types[q].clear();
6294
2/2
✓ Branch 0 taken 22784 times.
✓ Branch 1 taken 89 times.
22873 for(size_t q = 0; q < 256; ++q)
6295 22784 temp_misc.bottle_shop_types[q].clear();
6296 }
6297
6298
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 89 times.
119 if(s_version >= 14)
6299 {
6300 byte msfx;
6301
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 30 times.
7710 for(int32_t q = 0; q < sfxMAX; ++q)
6302 {
6303
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_getc(&msfx,f))
6304 return qe_invalid;
6305 7680 temp_misc.miscsfx[q] = msfx;
6306 7680 }
6307 30 }
6308 else
6309 {
6310 89 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6311 89 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6312 89 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6313 }
6314
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 89 times.
119 if(s_version < 15)
6315 {
6316 89 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6317 89 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6318 89 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6319 89 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6320 89 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6321 89 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6322 89 }
6323
6324 119 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6325
6326 119 return 0;
6327 123 }
6328
6329 extern char *item_string[MAXITEMS];
6330 extern const char *old_item_string[iLast];
6331 extern char *weapon_string[MAXWPNS];
6332 extern const char *old_weapon_string[wLast];
6333
6334 123 int32_t readitems(PACKFILE *f, word version, word build)
6335 {
6336 byte padding;
6337 int32_t dummy;
6338 123 word items_to_read=MAXITEMS;
6339 itemdata tempitem;
6340 123 word s_version=0, s_cversion=0;
6341 word dummy_word;
6342
6343
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(version < 0x186)
6344 {
6345 items_to_read=64;
6346 }
6347
6348
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 119 times.
123 if(version > 0x192)
6349 {
6350 119 items_to_read=0;
6351
6352 //section version info
6353
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&s_version,f))
6354 {
6355 return qe_invalid;
6356 }
6357
6358 119 FFCore.quest_format[vItems] = s_version;
6359
6360 //al_trace("Items version %d\n", s_version);
6361
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&s_cversion,f))
6362 {
6363 return qe_invalid;
6364 }
6365
6366 //section size
6367
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetl(&dummy,f))
6368 {
6369 return qe_invalid;
6370 }
6371
6372 //finally... section data
6373
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&items_to_read,f))
6374 {
6375 return qe_invalid;
6376 }
6377
6378
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
119 if (!(items_to_read >= 0 && items_to_read <= MAXITEMS))
6379 {
6380 return qe_invalid;
6381 }
6382 119 }
6383
6384
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if(s_version>1)
6385 {
6386
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 107 times.
27499 for(int32_t i=0; i<items_to_read; i++)
6387 {
6388 char tempname[64];
6389
6390
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(!pfread(tempname, 64, f))
6391 {
6392 return qe_invalid;
6393 }
6394
6395 27392 item_string[i][0] = '\0';
6396 27392 strncat(item_string[i], tempname, 64 - 1);
6397 27392 }
6398 107 }
6399 else
6400 {
6401
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXITEMS; i++)
6402 {
6403 4096 reset_itemname(i);
6404 4096 }
6405 }
6406
6407
2/2
✓ Branch 0 taken 31488 times.
✓ Branch 1 taken 123 times.
31611 for(int32_t i=0; i<MAXITEMS; i++)
6408 {
6409 31488 itemdata& id = itemsbuf[i];
6410 31488 memset(&id, 0, sizeof(itemdata));
6411 31488 id.count=-1;
6412 31488 id.playsound=WAV_SCALE;
6413 31488 reset_itembuf(&id,i);
6414 31488 }
6415
6416
2/2
✓ Branch 0 taken 29256 times.
✓ Branch 1 taken 123 times.
29379 for(int32_t i=0; i<items_to_read; i++)
6417 {
6418 29256 memset(&tempitem, 0, sizeof(itemdata));
6419 29256 reset_itembuf(&tempitem,i);
6420
6421
6422
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 21576 times.
29256 if ( s_version > 35 ) //expanded tiles
6423 {
6424
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.tile,f))
6425 {
6426 return qe_invalid;
6427 }
6428 7680 }
6429 else
6430 {
6431
1/2
✓ Branch 0 taken 21576 times.
✗ Branch 1 not taken.
21576 if(!p_igetw(&tempitem.tile,f))
6432 {
6433 return qe_invalid;
6434 }
6435 }
6436
6437
1/2
✓ Branch 0 taken 29256 times.
✗ Branch 1 not taken.
29256 if(!p_getc(&tempitem.misc_flags,f))
6438 {
6439 return qe_invalid;
6440 }
6441
6442
1/2
✓ Branch 0 taken 29256 times.
✗ Branch 1 not taken.
29256 if(!p_getc(&tempitem.csets,f))
6443 {
6444 return qe_invalid;
6445 }
6446
6447
1/2
✓ Branch 0 taken 29256 times.
✗ Branch 1 not taken.
29256 if(!p_getc(&tempitem.frames,f))
6448 {
6449 return qe_invalid;
6450 }
6451
6452
1/2
✓ Branch 0 taken 29256 times.
✗ Branch 1 not taken.
29256 if(!p_getc(&tempitem.speed,f))
6453 {
6454 return qe_invalid;
6455 }
6456
6457
1/2
✓ Branch 0 taken 29256 times.
✗ Branch 1 not taken.
29256 if(!p_getc(&tempitem.delay,f))
6458 {
6459 return qe_invalid;
6460 }
6461
6462
2/2
✓ Branch 0 taken 28232 times.
✓ Branch 1 taken 1024 times.
29256 if(version < 0x193)
6463 {
6464
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f))
6465 {
6466 return qe_invalid;
6467 }
6468
6469
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1024 if((version < 0x192)||((version == 0x192)&&(build<186)))
6470 {
6471
3/3
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
1024 switch(i)
6472 {
6473 case iShield:
6474 4 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6475 4 break;
6476
6477 case iMShield:
6478 4 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6479 4 break;
6480
6481 default:
6482 1016 tempitem.ltm=0;
6483 1016 break;
6484 }
6485
6486 1024 tempitem.count=-1;
6487 1024 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6488 1024 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6489 1024 tempitem.family=0xFF;
6490 1024 tempitem.playsound=WAV_SCALE;
6491 1024 reset_itembuf(&tempitem,i);
6492
6493 1024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6494
6495 1024 continue;
6496 }
6497 }
6498
6499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28232 times.
28232 if(!p_igetl(&tempitem.ltm,f))
6500 {
6501 return qe_invalid;
6502 }
6503
6504
1/2
✓ Branch 0 taken 28232 times.
✗ Branch 1 not taken.
28232 if(version < 0x193)
6505 {
6506 for(int32_t q=0; q<12; q++)
6507 {
6508 if(!p_getc(&padding,f))
6509 {
6510 return qe_invalid;
6511 }
6512 }
6513 }
6514
6515
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 840 times.
28232 if(s_version>1)
6516 {
6517
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 19712 times.
27392 if ( s_version >= 31 )
6518 {
6519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.family,f))
6520 {
6521 return qe_invalid;
6522 }
6523 7680 }
6524 else
6525 {
6526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19712 times.
19712 if(!p_getc(&tempitem.family,f))
6527 {
6528 return qe_invalid;
6529 }
6530 }
6531
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(s_version < 16)
6532 if(tempitem.family == 0xFF)
6533 tempitem.family = itype_misc;
6534
6535
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(!p_getc(&tempitem.fam_type,f))
6536 {
6537 return qe_invalid;
6538 }
6539
6540
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(s_version>5)
6541 {
6542
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 19712 times.
27392 if(s_version>=31)
6543 {
6544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.power,f))
6545 {
6546 return qe_invalid;
6547 }
6548 7680 }
6549 else
6550 {
6551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19712 times.
19712 if(!p_getc(&tempitem.power,f))
6552 {
6553 return qe_invalid;
6554 }
6555 }
6556
6557 //converted flags from 16b to 32b -Z
6558
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 7680 times.
27392 if ( s_version < 41 )
6559 {
6560
1/2
✓ Branch 0 taken 19712 times.
✗ Branch 1 not taken.
19712 if(!p_igetw(&tempitem.flags,f))
6561 {
6562 return qe_invalid;
6563 }
6564 19712 }
6565 else
6566 {
6567
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.flags,f))
6568 {
6569 return qe_invalid;
6570 }
6571 }
6572 27392 }
6573 else
6574 {
6575 //tempitem.power = tempitem.fam_type;
6576 char tempchar;
6577
6578 if(!p_getc(&tempchar,f))
6579 {
6580 return qe_invalid;
6581 }
6582
6583 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6584 }
6585
6586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27392 times.
27392 if(!p_igetw(&tempitem.script,f))
6587 {
6588 return qe_invalid;
6589 }
6590
6591
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(s_version<=3)
6592 {
6593 if(tempitem.script > NUMSCRIPTITEM)
6594 {
6595 tempitem.script = 0;
6596 }
6597 }
6598
6599
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(!p_getc(&tempitem.count,f))
6600 {
6601 return qe_invalid;
6602 }
6603
6604
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(!p_igetw(&tempitem.amount,f))
6605 {
6606 return qe_invalid;
6607 }
6608
6609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27392 times.
27392 if(!p_igetw(&tempitem.collect_script,f))
6610 {
6611 return qe_invalid;
6612 }
6613
6614
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(s_version<=3)
6615 {
6616 if(tempitem.collect_script > NUMSCRIPTITEM)
6617 {
6618 tempitem.collect_script = 0;
6619 }
6620 }
6621
6622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27392 times.
27392 if(!p_igetw(&tempitem.setmax,f))
6623 {
6624 return qe_invalid;
6625 }
6626
6627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27392 times.
27392 if(!p_igetw(&tempitem.max,f))
6628 {
6629 return qe_invalid;
6630 }
6631
6632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27392 times.
27392 if(!p_getc(&tempitem.playsound,f))
6633 {
6634 return qe_invalid;
6635 }
6636
6637
2/2
✓ Branch 0 taken 219136 times.
✓ Branch 1 taken 27392 times.
246528 for(int32_t j=0; j<8; j++)
6638 {
6639
1/2
✓ Branch 0 taken 219136 times.
✗ Branch 1 not taken.
219136 if(!p_igetl(&tempitem.initiald[j],f))
6640 {
6641 return qe_invalid;
6642 }
6643 219136 }
6644
6645
2/2
✓ Branch 0 taken 54784 times.
✓ Branch 1 taken 27392 times.
82176 for(int32_t j=0; j<2; j++)
6646 {
6647
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_getc(&tempitem.initiala[j],f))
6648 {
6649 return qe_invalid;
6650 }
6651 54784 }
6652
6653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27392 times.
27392 if(s_version>4)
6654 {
6655
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(s_version>5)
6656 {
6657
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(!p_getc(&tempitem.wpn,f))
6658 {
6659 return qe_invalid;
6660 }
6661
6662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27392 times.
27392 if(!p_getc(&tempitem.wpn2,f))
6663 {
6664 return qe_invalid;
6665 }
6666
6667
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(!p_getc(&tempitem.wpn3,f))
6668 {
6669 return qe_invalid;
6670 }
6671
6672
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(!p_getc(&tempitem.wpn4,f))
6673 {
6674 return qe_invalid;
6675 }
6676
6677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27392 times.
27392 if(s_version>=15)
6678 {
6679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27392 times.
27392 if(!p_getc(&tempitem.wpn5,f))
6680 {
6681 return qe_invalid;
6682 }
6683
6684
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(!p_getc(&tempitem.wpn6,f))
6685 {
6686 return qe_invalid;
6687 }
6688
6689
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(!p_getc(&tempitem.wpn7,f))
6690 {
6691 return qe_invalid;
6692 }
6693
6694
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(!p_getc(&tempitem.wpn8,f))
6695 {
6696 return qe_invalid;
6697 }
6698
6699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27392 times.
27392 if(!p_getc(&tempitem.wpn9,f))
6700 {
6701 return qe_invalid;
6702 }
6703
6704
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(!p_getc(&tempitem.wpn10,f))
6705 {
6706 return qe_invalid;
6707 }
6708 27392 }
6709
6710
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(!p_getc(&tempitem.pickup_hearts,f))
6711 {
6712 return qe_invalid;
6713 }
6714
6715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27392 times.
27392 if(s_version<15)
6716 {
6717 if(!p_igetw(&dummy_word,f))
6718 {
6719 return qe_invalid;
6720 }
6721
6722 tempitem.misc1=dummy_word;
6723
6724 if(!p_igetw(&dummy_word,f))
6725 {
6726 return qe_invalid;
6727 }
6728
6729 tempitem.misc2=dummy_word;
6730 }
6731 else
6732 {
6733
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(!p_igetl(&tempitem.misc1,f))
6734 {
6735 return qe_invalid;
6736 }
6737
6738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27392 times.
27392 if(!p_igetl(&tempitem.misc2,f))
6739 {
6740 return qe_invalid;
6741 }
6742
6743 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6744
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(s_version<24)
6745 {
6746 if(tempitem.family==itype_shield)
6747 {
6748 tempitem.misc1|=shSCRIPT;
6749 }
6750 }
6751 }
6752
6753
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 7680 times.
27392 if(s_version < 53)
6754 {
6755 byte tempbyte;
6756
1/2
✓ Branch 0 taken 19712 times.
✗ Branch 1 not taken.
19712 if(!p_getc(&tempbyte,f))
6757 {
6758 return qe_invalid;
6759 }
6760 19712 tempitem.cost_amount[0] = tempbyte;
6761 19712 }
6762 else
6763 {
6764
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 7680 times.
23040 for(auto q = 0; q < 2; ++q)
6765 {
6766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15360 times.
15360 if(!p_igetw(&tempitem.cost_amount[q],f))
6767 {
6768 return qe_invalid;
6769 }
6770 15360 }
6771 }
6772 27392 }
6773 else
6774 {
6775 char tempchar;
6776
6777 if(!p_getc(&tempchar,f))
6778 {
6779 return qe_invalid;
6780 }
6781
6782 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6783 }
6784
6785 // June 2007: more misc. attributes
6786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27392 times.
27392 if(s_version>=12)
6787 {
6788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27392 times.
27392 if(s_version<15)
6789 {
6790 if(!p_igetw(&dummy_word,f))
6791 {
6792 return qe_invalid;
6793 }
6794
6795 tempitem.misc3=dummy_word;
6796
6797 if(!p_igetw(&dummy_word,f))
6798 {
6799 return qe_invalid;
6800 }
6801
6802 tempitem.misc4=dummy_word;
6803 }
6804 else
6805 {
6806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27392 times.
27392 if(!p_igetl(&tempitem.misc3,f))
6807 {
6808 return qe_invalid;
6809 }
6810
6811
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(!p_igetl(&tempitem.misc4,f))
6812 {
6813 return qe_invalid;
6814 }
6815
6816
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(!p_igetl(&tempitem.misc5,f))
6817 {
6818 return qe_invalid;
6819 }
6820
6821
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(!p_igetl(&tempitem.misc6,f))
6822 {
6823 return qe_invalid;
6824 }
6825
6826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27392 times.
27392 if(!p_igetl(&tempitem.misc7,f))
6827 {
6828 return qe_invalid;
6829 }
6830
6831
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(!p_igetl(&tempitem.misc8,f))
6832 {
6833 return qe_invalid;
6834 }
6835
6836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27392 times.
27392 if(!p_igetl(&tempitem.misc9,f))
6837 {
6838 return qe_invalid;
6839 }
6840
6841
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(!p_igetl(&tempitem.misc10,f))
6842 {
6843 return qe_invalid;
6844 }
6845 }
6846
6847
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(!p_getc(&tempitem.usesound,f))
6848 {
6849 return qe_invalid;
6850 }
6851
6852
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 19712 times.
27392 if(s_version >= 49)
6853 {
6854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_getc(&tempitem.usesound2,f))
6855 {
6856 return qe_invalid;
6857 }
6858 7680 }
6859 19712 else tempitem.usesound2 = 0;
6860
6861
3/4
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 7680 times.
✓ Branch 2 taken 19712 times.
✗ Branch 3 not taken.
27392 if(s_version < 50 && tempitem.family == itype_mirror)
6862 {
6863 //Split continue/dmap warp effect/sfx, port for old
6864 tempitem.misc2 = tempitem.misc1;
6865 tempitem.usesound2 = tempitem.usesound;
6866 }
6867 27392 }
6868 27392 }
6869
6870
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 7680 times.
27392 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6871 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_getc(&tempitem.useweapon,f))
6873 {
6874 return qe_invalid;
6875 }
6876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_getc(&tempitem.usedefence,f))
6877 {
6878 return qe_invalid;
6879 }
6880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.weaprange,f))
6881 {
6882 return qe_invalid;
6883 }
6884
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.weapduration,f))
6885 {
6886 return qe_invalid;
6887 }
6888
2/2
✓ Branch 0 taken 76800 times.
✓ Branch 1 taken 7680 times.
84480 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6889 {
6890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76800 times.
76800 if(!p_igetl(&tempitem.weap_pattern[q],f))
6891 {
6892 return qe_invalid;
6893 }
6894 76800 }
6895 7680 }
6896
6897
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 7680 times.
27392 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6898 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6899
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.duplicates,f))
6900 {
6901 return qe_invalid;
6902 }
6903
2/2
✓ Branch 0 taken 61440 times.
✓ Branch 1 taken 7680 times.
69120 for ( int32_t q = 0; q < INITIAL_D; q++ )
6904 {
6905
1/2
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
61440 if(!p_igetl(&tempitem.weap_initiald[q],f))
6906 {
6907 return qe_invalid;
6908 }
6909 61440 }
6910
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 7680 times.
23040 for ( int32_t q = 0; q < INITIAL_A; q++ )
6911 {
6912
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_getc(&tempitem.weap_initiala[q],f))
6913 {
6914 return qe_invalid;
6915 }
6916 15360 }
6917
6918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_getc(&tempitem.drawlayer,f))
6919 {
6920 return qe_invalid;
6921 }
6922
6923
6924
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.hxofs,f))
6925 {
6926 return qe_invalid;
6927 }
6928
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.hyofs,f))
6929 {
6930 return qe_invalid;
6931 }
6932
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.hxsz,f))
6933 {
6934 return qe_invalid;
6935 }
6936
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.hysz,f))
6937 {
6938 return qe_invalid;
6939 }
6940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.hzsz,f))
6941 {
6942 return qe_invalid;
6943 }
6944
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.xofs,f))
6945 {
6946 return qe_invalid;
6947 }
6948
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.yofs,f))
6949 {
6950 return qe_invalid;
6951 }
6952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.weap_hxofs,f))
6953 {
6954 return qe_invalid;
6955 }
6956
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.weap_hyofs,f))
6957 {
6958 return qe_invalid;
6959 }
6960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.weap_hxsz,f))
6961 {
6962 return qe_invalid;
6963 }
6964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.weap_hysz,f))
6965 {
6966 return qe_invalid;
6967 }
6968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.weap_hzsz,f))
6969 {
6970 return qe_invalid;
6971 }
6972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.weap_xofs,f))
6973 {
6974 return qe_invalid;
6975 }
6976
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.weap_yofs,f))
6977 {
6978 return qe_invalid;
6979 }
6980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetw(&tempitem.weaponscript,f))
6981 {
6982 return qe_invalid;
6983 }
6984
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.wpnsprite,f))
6985 {
6986 return qe_invalid;
6987 }
6988 7680 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6989
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 7680 times.
23040 for(auto q = 0; q < num_cost_tmr; ++q)
6990 {
6991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15360 times.
15360 if(!p_igetl(&tempitem.magiccosttimer[q],f))
6992 {
6993 return qe_invalid;
6994 }
6995 15360 }
6996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 for(auto q = num_cost_tmr; q < 2; ++q)
6997 tempitem.magiccosttimer[q] = 0;
6998 7680 }
6999
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 7680 times.
27392 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
7000 {
7001 //Item Size FLags, TileWidth, TileHeight
7002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.overrideFLAGS,f))
7003 {
7004 return qe_invalid;
7005 }
7006
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.tilew,f))
7007 {
7008 return qe_invalid;
7009 }
7010
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.tileh,f))
7011 {
7012 return qe_invalid;
7013 }
7014 7680 }
7015
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 7680 times.
27392 if ( s_version >= 29 ) //! More new vars.
7016 {
7017 //Item Size FLags, TileWidth, TileHeight
7018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.weapoverrideFLAGS,f))
7019 {
7020 return qe_invalid;
7021 }
7022
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.weap_tilew,f))
7023 {
7024 return qe_invalid;
7025 }
7026
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.weap_tileh,f))
7027 {
7028 return qe_invalid;
7029 }
7030 7680 }
7031
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 7680 times.
27392 if ( s_version >= 30 ) //! More new vars.
7032 {
7033 //Pickup Type
7034
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.pickup,f))
7035 {
7036 return qe_invalid;
7037 }
7038 7680 }
7039
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 7680 times.
27392 if ( s_version >= 32 ) //! More new vars.
7040 {
7041 //Pickup Type
7042
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetw(&tempitem.pstring,f))
7043 {
7044 return qe_invalid;
7045 }
7046 7680 }
7047
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 7680 times.
27392 if ( s_version >= 33 ) //! More new vars.
7048 {
7049 //Pickup Type
7050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetw(&tempitem.pickup_string_flags,f))
7051 {
7052 return qe_invalid;
7053 }
7054 7680 }
7055
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 7680 times.
27392 if ( s_version >= 34 ) //! cost counter
7056 {
7057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(s_version < 53)
7058 {
7059 if(!p_getc(&tempitem.cost_counter[0],f))
7060 {
7061 return qe_invalid;
7062 }
7063 }
7064 else
7065 {
7066
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 7680 times.
23040 for(auto q = 0; q < 2; ++q)
7067 {
7068
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_getc(&tempitem.cost_counter[q],f))
7069 {
7070 return qe_invalid;
7071 }
7072 15360 }
7073 }
7074 7680 }
7075
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 7680 times.
27392 if ( s_version >= 44 ) //! sprite scripts
7076 {
7077
2/2
✓ Branch 0 taken 61440 times.
✓ Branch 1 taken 7680 times.
69120 for ( int32_t q = 0; q < 8; q++ )
7078 {
7079
2/2
✓ Branch 0 taken 3993600 times.
✓ Branch 1 taken 61440 times.
4055040 for ( int32_t w = 0; w < 65; w++ )
7080 {
7081
1/2
✓ Branch 0 taken 3993600 times.
✗ Branch 1 not taken.
3993600 if(!p_getc(&(tempitem.initD_label[q][w]),f))
7082 {
7083 return qe_invalid;
7084 }
7085 3993600 }
7086
2/2
✓ Branch 0 taken 3993600 times.
✓ Branch 1 taken 61440 times.
4055040 for ( int32_t w = 0; w < 65; w++ )
7087 {
7088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3993600 times.
3993600 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f))
7089 {
7090 return qe_invalid;
7091 }
7092 3993600 }
7093
2/2
✓ Branch 0 taken 3993600 times.
✓ Branch 1 taken 61440 times.
4055040 for ( int32_t w = 0; w < 65; w++ )
7094 {
7095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3993600 times.
3993600 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
7096 {
7097 return qe_invalid;
7098 }
7099 3993600 }
7100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61440 times.
61440 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
7101 {
7102 return qe_invalid;
7103 }
7104
7105 61440 }
7106
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 7680 times.
23040 for ( int32_t q = 0; q < 2; q++ )
7107 {
7108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15360 times.
15360 if(!p_getc(&(tempitem.sprite_initiala[q]),f))
7109 {
7110 return qe_invalid;
7111 }
7112 15360 }
7113 //Pickup Type
7114
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetw(&tempitem.sprite_script,f))
7115 {
7116 return qe_invalid;
7117 }
7118 7680 }
7119
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 7680 times.
27392 if ( s_version >= 48 ) //! pickup flags
7120 {
7121
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_getc(&(tempitem.pickupflag),f))
7122 {
7123 return qe_invalid;
7124 }
7125 7680 }
7126
2/2
✓ Branch 0 taken 21248 times.
✓ Branch 1 taken 6144 times.
27392 if ( s_version >= 57 )
7127 {
7128 6144 std::string str;
7129
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
✓ Branch 2 taken 6144 times.
✗ Branch 3 not taken.
6144 if(!p_getcstr(&str,f))
7130 return qe_invalid;
7131 6144 strncpy(tempitem.display_name,str.c_str(),255);
7132
1/3
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
6144 }
7133 27392 }
7134 else
7135 {
7136 840 tempitem.count=-1;
7137 840 tempitem.family=itype_misc;
7138 840 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7139 840 tempitem.playsound=WAV_SCALE;
7140 840 reset_itembuf(&tempitem,i);
7141 }
7142
7143 28232 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7144 28232 }
7145
7146 //////////////////////////////////////////////////////
7147 // Now do any updates because of new item additions
7148 // (These can't be done above because items_to_read
7149 // might be too low.)
7150 //////////////////////////////////////////////////////
7151
2/2
✓ Branch 0 taken 31488 times.
✓ Branch 1 taken 123 times.
31611 for(int32_t i=0; i<MAXITEMS; i++)
7152 {
7153 31488 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7154
7155 //Account for older quests that didn't have an actual item for the used letter
7156
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 27392 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
31488 if(s_version < 2 && i==iLetterUsed)
7157 {
7158 16 reset_itembuf(&tempitem, iLetterUsed);
7159 16 strcpy(item_string[i],old_item_string[i]);
7160 16 tempitem.tile = itemsbuf[iLetter].tile;
7161 16 tempitem.csets = itemsbuf[iLetter].csets;
7162 16 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7163 16 tempitem.frames = itemsbuf[iLetter].frames;
7164 16 tempitem.speed = itemsbuf[iLetter].speed;
7165 16 tempitem.ltm = itemsbuf[iLetter].ltm;
7166 16 }
7167
7168
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 4096 times.
31488 if(s_version < 3)
7169 {
7170
3/3
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 3728 times.
✓ Branch 2 taken 16 times.
4096 switch(i)
7171 {
7172 case iRocsFeather:
7173 case iHoverBoots:
7174 case iSpinScroll:
7175 case iL2SpinScroll:
7176 case iCrossScroll:
7177 case iQuakeScroll:
7178 case iL2QuakeScroll:
7179 case iWhispRing:
7180 case iL2WhispRing:
7181 case iChargeRing:
7182 case iL2ChargeRing:
7183 case iPerilScroll:
7184 case iWalletL3:
7185 case iQuiverL4:
7186 case iBombBagL4:
7187 case iBracelet:
7188 case iL2Bracelet:
7189 case iOldGlove:
7190 case iL2Ladder:
7191 case iWealthMedal:
7192 case iL2WealthMedal:
7193 case iL3WealthMedal:
7194 352 reset_itembuf(&tempitem, i);
7195 352 strcpy(item_string[i],old_item_string[i]);
7196 352 break;
7197
7198 case iSShield:
7199 16 reset_itembuf(&tempitem, i);
7200 16 strcpy(item_string[i],old_item_string[i]);
7201 16 strcpy(item_string[iShield],old_item_string[iShield]);
7202 16 strcpy(item_string[iMShield],old_item_string[iMShield]);
7203 16 break;
7204 }
7205 4096 }
7206
7207
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 4096 times.
31488 if(s_version < 5)
7208 {
7209
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 3984 times.
4096 switch(i)
7210 {
7211 case iHeartRing:
7212 case iL2HeartRing:
7213 case iL3HeartRing:
7214 case iMagicRing:
7215 case iL2MagicRing:
7216 case iL3MagicRing:
7217 case iL4MagicRing:
7218 112 reset_itembuf(&tempitem, i);
7219 112 strcpy(item_string[i],old_item_string[i]);
7220 112 break;
7221 }
7222 4096 }
7223
7224
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 4096 times.
31488 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7225 {
7226
4/4
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4064 times.
4096 if(i!=iBPotion && i!=iRPotion)
7227 4064 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7228
7229
43/43
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 16 times.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 16 times.
✓ Branch 15 taken 16 times.
✓ Branch 16 taken 16 times.
✓ Branch 17 taken 16 times.
✓ Branch 18 taken 16 times.
✓ Branch 19 taken 16 times.
✓ Branch 20 taken 16 times.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 64 times.
✓ Branch 23 taken 3376 times.
✓ Branch 24 taken 16 times.
✓ Branch 25 taken 16 times.
✓ Branch 26 taken 16 times.
✓ Branch 27 taken 16 times.
✓ Branch 28 taken 16 times.
✓ Branch 29 taken 16 times.
✓ Branch 30 taken 16 times.
✓ Branch 31 taken 16 times.
✓ Branch 32 taken 16 times.
✓ Branch 33 taken 16 times.
✓ Branch 34 taken 16 times.
✓ Branch 35 taken 16 times.
✓ Branch 36 taken 16 times.
✓ Branch 37 taken 16 times.
✓ Branch 38 taken 16 times.
✓ Branch 39 taken 16 times.
✓ Branch 40 taken 16 times.
✓ Branch 41 taken 16 times.
✓ Branch 42 taken 16 times.
4096 switch(i)
7230 {
7231 case iTriforce:
7232 16 tempitem.fam_type=1;
7233 16 break;
7234
7235 case iBigTri:
7236 16 tempitem.fam_type=0;
7237 16 break;
7238
7239 case iBombs:
7240 16 tempitem.fam_type=i_bomb;
7241 16 tempitem.power=4;
7242 16 tempitem.wpn=wBOMB;
7243 16 tempitem.wpn2=wBOOM;
7244 16 tempitem.misc1 = 50;
7245
7246
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7247
7248 16 break;
7249
7250 case iSBomb:
7251 16 tempitem.fam_type=i_sbomb;
7252 16 tempitem.power=16;
7253 16 tempitem.wpn=wSBOMB;
7254 16 tempitem.wpn2=wSBOOM;
7255 16 tempitem.misc1 = 50;
7256
7257
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7258
7259 16 break;
7260
7261 case iBook:
7262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7263 tempitem.wpn = wFIREMAGIC;
7264
7265 16 break;
7266
7267 case iSArrow:
7268 16 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7269 16 tempitem.power=4;
7270 16 tempitem.flags|=ITEM_GAMEDATA;
7271 16 tempitem.wpn=wSARROW;
7272 16 break;
7273
7274 case iGArrow:
7275 16 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7276 16 tempitem.power=8;
7277 16 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7278 16 tempitem.wpn=wGARROW;
7279 16 break;
7280
7281 case iBrang:
7282 16 tempitem.power=0;
7283 16 tempitem.wpn=wBRANG;
7284 16 tempitem.misc1=36;
7285 16 break;
7286
7287 case iMBrang:
7288 16 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7289 16 tempitem.power=0;
7290 16 tempitem.wpn=wMBRANG;
7291 16 break;
7292
7293 case iFBrang:
7294 16 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7295 16 tempitem.power=2;
7296 16 tempitem.wpn=wFBRANG;
7297 16 break;
7298
7299 case iBoots:
7300 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7301 16 tempitem.power=7;
7302 16 break;
7303
7304 case iWand:
7305 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7306 16 tempitem.power=2;
7307 16 tempitem.wpn=wWAND;
7308 16 tempitem.wpn3=wMAGIC;
7309 16 break;
7310
7311 case iBCandle:
7312 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7313 16 tempitem.power=1;
7314 16 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7315 16 tempitem.wpn3=wFIRE;
7316 16 break;
7317
7318 case iRCandle:
7319 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7320 16 tempitem.power=1;
7321 16 tempitem.wpn3=wFIRE;
7322 16 break;
7323
7324 case iSword:
7325 16 tempitem.power=1;
7326 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7327 16 tempitem.wpn=tempitem.wpn3=wSWORD;
7328 16 tempitem.wpn2=wSWORDSLASH;
7329 16 break;
7330
7331 case iWSword:
7332 16 tempitem.power=2;
7333 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7334 16 tempitem.wpn=tempitem.wpn3=wWSWORD;
7335 16 tempitem.wpn2=wWSWORDSLASH;
7336 16 break;
7337
7338 case iMSword:
7339 16 tempitem.power=4;
7340 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7341 16 tempitem.wpn=tempitem.wpn3=wMSWORD;
7342 16 tempitem.wpn2=wMSWORDSLASH;
7343 16 break;
7344
7345 case iXSword:
7346 16 tempitem.power=8;
7347 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7348 16 tempitem.wpn=tempitem.wpn3=wXSWORD;
7349 16 tempitem.wpn2=wXSWORDSLASH;
7350 16 break;
7351
7352 case iDivineProtection:
7353 16 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG1 : 0;
7354 16 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG2 : 0;
7355 16 tempitem.wpn=wDIVINEPROTECTION1A;
7356 16 tempitem.wpn2=wDIVINEPROTECTION1B;
7357 16 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7358 16 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7359 16 tempitem.wpn6=wDIVINEPROTECTION2A;
7360 16 tempitem.wpn7=wDIVINEPROTECTION2B;
7361 16 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7362 16 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7363 16 tempitem.wpn5 = iwDivineProtectionShieldFront;
7364 16 tempitem.wpn10 = iwDivineProtectionShieldBack;
7365 16 tempitem.misc1=512;
7366 16 tempitem.cost_amount[0]=64;
7367 16 break;
7368
7369 case iLens:
7370 16 tempitem.misc1=60;
7371 16 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7372 16 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7373 16 break;
7374
7375 case iArrow:
7376 16 tempitem.power=2;
7377 16 tempitem.wpn=wARROW;
7378 16 break;
7379
7380 case iHoverBoots:
7381 16 tempitem.misc1=45;
7382 16 tempitem.wpn=iwHover;
7383 16 break;
7384
7385 case iDivineFire:
7386 16 tempitem.power=8;
7387 16 tempitem.wpn=wDIVINEFIRE1A;
7388 16 tempitem.wpn2=wDIVINEFIRE1B;
7389 16 tempitem.wpn3=wDIVINEFIRES1A;
7390 16 tempitem.wpn4=wDIVINEFIRES1B;
7391 16 tempitem.misc1 = 32;
7392 16 tempitem.misc2 = 200;
7393 16 tempitem.cost_amount[0]=32;
7394 16 break;
7395
7396 case iDivineEscape:
7397 16 tempitem.cost_amount[0]=32;
7398 16 break;
7399
7400 case iHookshot:
7401 16 tempitem.power=0;
7402 16 tempitem.flags&=~ITEM_FLAG1;
7403 16 tempitem.wpn=wHSHEAD;
7404 16 tempitem.wpn2=wHSCHAIN_H;
7405 16 tempitem.wpn4=wHSHANDLE;
7406 16 tempitem.wpn3=wHSCHAIN_V;
7407 16 tempitem.misc1=50;
7408 16 tempitem.misc2=100;
7409 16 break;
7410
7411 case iLongshot:
7412 16 tempitem.power=0;
7413 16 tempitem.flags&=~ITEM_FLAG1;
7414 16 tempitem.wpn=wLSHEAD;
7415 16 tempitem.wpn2=wLSCHAIN_H;
7416 16 tempitem.wpn4=wLSHANDLE;
7417 16 tempitem.wpn3=wLSCHAIN_V;
7418 16 tempitem.misc1=99;
7419 16 tempitem.misc2=100;
7420 16 break;
7421
7422 case iHammer:
7423 16 tempitem.power=4;
7424 16 tempitem.wpn=wHAMMER;
7425 16 tempitem.wpn2=iwHammerSmack;
7426 16 break;
7427
7428 case iCByrna:
7429 16 tempitem.power=1;
7430 16 tempitem.wpn=wCBYRNA;
7431 16 tempitem.wpn2=wCBYRNASLASH;
7432 16 tempitem.wpn3=wCBYRNAORB;
7433 16 tempitem.misc1=4;
7434 16 tempitem.misc2=16;
7435 16 tempitem.misc3=1;
7436 16 tempitem.cost_amount[0]=1;
7437 16 break;
7438
7439 case iWhistle:
7440 16 tempitem.wpn=wWIND;
7441 16 tempitem.misc1=3;
7442 16 tempitem.flags|=ITEM_FLAG1;
7443 16 break;
7444
7445 case iBRing:
7446 16 tempitem.power=2;
7447 16 tempitem.misc1=spBLUE;
7448 16 break;
7449
7450 case iRRing:
7451 16 tempitem.power=4;
7452 16 tempitem.misc1=spRED;
7453 16 break;
7454
7455 case iGRing:
7456 16 tempitem.power=8;
7457 16 tempitem.misc1=spGOLD;
7458 16 break;
7459
7460 case iSpinScroll:
7461 16 tempitem.power = 2;
7462 16 tempitem.misc1 = 1;
7463 16 break;
7464
7465 case iL2SpinScroll:
7466 16 tempitem.family=itype_spinscroll2;
7467 16 tempitem.fam_type=1;
7468 16 tempitem.cost_amount[0]=8;
7469 16 tempitem.power=2;
7470 16 tempitem.misc1 = 20;
7471 16 break;
7472
7473 case iQuakeScroll:
7474 16 tempitem.misc1=0x10;
7475 16 tempitem.misc2=64;
7476 16 break;
7477
7478 case iL2QuakeScroll:
7479 16 tempitem.family=itype_quakescroll2;
7480 16 tempitem.fam_type=1;
7481 16 tempitem.power = 2;
7482 16 tempitem.misc1=0x20;
7483 16 tempitem.misc2=192;
7484 16 tempitem.cost_amount[0]=8;
7485 16 break;
7486
7487 case iChargeRing:
7488 16 tempitem.misc1=64;
7489 16 tempitem.misc2=128;
7490 16 break;
7491
7492 case iL2ChargeRing:
7493 16 tempitem.misc1=32;
7494 16 tempitem.misc2=64;
7495 16 break;
7496
7497 case iOldGlove:
7498 16 tempitem.flags |= ITEM_FLAG1;
7499
7500 //fallthrough
7501 case iBombBagL4:
7502 case iWalletL3:
7503 case iQuiverL4:
7504 case iBracelet:
7505 80 tempitem.power = 1;
7506 80 break;
7507
7508 case iL2Bracelet:
7509 16 tempitem.power = 2;
7510 16 break;
7511
7512 case iMKey:
7513 16 tempitem.power=0xFF;
7514 16 tempitem.flags |= ITEM_FLAG1;
7515 16 break;
7516 }
7517 4096 }
7518
7519
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 4096 times.
31488 if(s_version < 7)
7520 {
7521
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4032 times.
4096 switch(i)
7522 {
7523 case iStoneAgony:
7524 case iStompBoots:
7525 case iPerilRing:
7526 case iWhimsicalRing:
7527 {
7528 64 reset_itembuf(&tempitem, i);
7529 64 strcpy(item_string[i],old_item_string[i]);
7530 64 break;
7531 }
7532 }
7533 4096 }
7534
7535
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 4096 times.
31488 if(s_version < 8) // May 2007: Some corrections.
7536 {
7537
7/7
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 3968 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
4096 switch(i)
7538 {
7539 case iMShield:
7540 16 tempitem.misc1|=shFLAME;
7541 16 tempitem.misc2|=shFIREBALL|shMAGIC;
7542
7543
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_qr(qr_SWORDMIRROR))
7544 {
7545 tempitem.misc2 |= shSWORD;
7546 }
7547
7548 // fallthrough
7549 case iShield:
7550 32 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7551
7552 // fallthrough
7553 case iSShield:
7554 48 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7555
7556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7557 {
7558 tempitem.misc2 |= shROCK;
7559 }
7560
7561 48 break;
7562
7563 case iWhispRing:
7564 16 tempitem.power=1;
7565 16 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7566 16 tempitem.misc1 = 3;
7567 16 break;
7568
7569 case iL2WhispRing:
7570 16 tempitem.power=0;
7571 16 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7572 16 tempitem.misc1 = 3;
7573 16 break;
7574
7575 case iL2Ladder:
7576 case iBow:
7577 case iCByrna:
7578 48 tempitem.power = 1;
7579 48 break;
7580 }
7581 4096 }
7582
7583
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 27392 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
31488 if(s_version < 9 && i==iClock)
7584 {
7585 16 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7586 16 }
7587
7588 //add the misc flag for bomb
7589
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 27392 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
31488 if(s_version < 10 && tempitem.family == itype_bomb)
7590 {
7591 16 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7592 16 }
7593
7594
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 27392 times.
✓ Branch 2 taken 4064 times.
✓ Branch 3 taken 32 times.
31488 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7595 {
7596 32 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7597 32 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7598 32 }
7599
7600
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 4096 times.
31488 if(s_version < 12) // June 2007: More Misc. attributes.
7601 {
7602
5/5
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4016 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
4096 switch(i)
7603 {
7604 case iFBrang:
7605 16 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7606
7607 //fallthrough
7608 case iMBrang:
7609 32 tempitem.misc3 |= shSWORD|shMAGIC;
7610
7611 //fallthrough
7612 case iHookshot:
7613 case iLongshot:
7614 //fallthrough
7615 64 tempitem.misc3 |= shFIREBALL;
7616
7617 case iBrang:
7618 80 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7619 80 break;
7620 }
7621
7622
16/16
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 48 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 1740 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 16 times.
✓ Branch 13 taken 64 times.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 1956 times.
4096 switch(tempitem.family)
7623 {
7624 case itype_hoverboots:
7625 16 tempitem.usesound = WAV_ZN1HOVER;
7626 16 break;
7627
7628 case itype_wand:
7629 16 tempitem.usesound = WAV_WAND;
7630 16 break;
7631
7632 case itype_book:
7633 16 tempitem.usesound = WAV_FIRE;
7634 16 break;
7635
7636 case itype_arrow:
7637 48 tempitem.usesound = WAV_ARROW;
7638 48 break;
7639
7640 case itype_hookshot:
7641 32 tempitem.usesound = WAV_HOOKSHOT;
7642 32 break;
7643
7644 case itype_brang:
7645 48 tempitem.usesound = WAV_BRANG;
7646 48 break;
7647
7648 case itype_shield:
7649 48 tempitem.usesound = WAV_CHINK;
7650 48 break;
7651
7652 case itype_sword:
7653 1740 tempitem.usesound = WAV_SWORD;
7654 1740 break;
7655
7656 case itype_whistle:
7657 16 tempitem.usesound = WAV_WHISTLE;
7658 16 break;
7659
7660 case itype_hammer:
7661 16 tempitem.usesound = WAV_HAMMER;
7662 16 break;
7663
7664 case itype_divinefire:
7665 16 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7666 16 break;
7667
7668 case itype_divineescape:
7669 16 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7670 16 break;
7671
7672 case itype_divineprotection:
7673 16 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7674 16 break;
7675
7676 case itype_bomb:
7677 case itype_sbomb:
7678 case itype_quakescroll:
7679 case itype_quakescroll2:
7680 64 tempitem.usesound = WAV_BOMB;
7681 64 break;
7682
7683 case itype_spinscroll:
7684 case itype_spinscroll2:
7685 32 tempitem.usesound = WAV_ZN1SPINATTACK;
7686 32 break;
7687 }
7688 4096 }
7689
7690
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 4096 times.
31488 if(s_version < 13) // July 2007
7691 {
7692
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_whistle)
7693 {
7694 16 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7695 16 tempitem.power = 1;
7696 16 tempitem.flags|=ITEM_FLAG1;
7697 16 }
7698
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4064 times.
4080 else if(tempitem.family == itype_wand)
7699 16 tempitem.flags|=ITEM_FLAG1;
7700
2/2
✓ Branch 0 taken 4048 times.
✓ Branch 1 taken 16 times.
4064 else if(tempitem.family == itype_book)
7701 {
7702 16 tempitem.flags|=ITEM_FLAG1;
7703 16 tempitem.power = 2;
7704 16 }
7705 4096 }
7706
7707
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 4096 times.
31488 if(s_version < 14) // August 2007
7708 {
7709
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4064 times.
4096 if(tempitem.family == itype_fairy)
7710 {
7711 32 tempitem.usesound = WAV_SCALE;
7712
7713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(tempitem.fam_type)
7714 32 tempitem.misc3=50;
7715 32 }
7716
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 32 times.
4064 else if(tempitem.family == itype_potion)
7717 {
7718 32 tempitem.flags |= ITEM_GAINOLD;
7719 32 }
7720 4096 }
7721
7722
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 4096 times.
31488 if(s_version < 17) // November 2007
7723 {
7724
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
4096 if(tempitem.family == itype_candle && !tempitem.wpn3)
7725 {
7726 tempitem.wpn3 = wFIRE;
7727 }
7728
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 4048 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 16 times.
4096 else if(tempitem.family == itype_arrow && tempitem.power>4)
7729 {
7730 16 tempitem.flags|=ITEM_FLAG1;
7731 16 }
7732 4096 }
7733
7734
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 4096 times.
31488 if(s_version < 18) // New Year's Eve 2007
7735 {
7736
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_whistle)
7737 16 tempitem.misc2 = 8; // Use the Whistle warp ring
7738
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4064 times.
4080 else if(tempitem.family == itype_bait)
7739 16 tempitem.misc1 = 768; // Frames until it goes
7740
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 32 times.
4064 else if(tempitem.family == itype_triforcepiece)
7741 {
7742
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
32 if(tempitem.flags & ITEM_GAMEDATA)
7743 {
7744 16 tempitem.misc2 = 1; // Cutscene 1
7745 16 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7746 16 }
7747 32 }
7748 4096 }
7749
7750
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 4096 times.
31488 if(s_version < 19) // January 2008
7751 {
7752
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divineprotection)
7753 {
7754 16 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7755 16 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7756 16 }
7757 4096 }
7758
7759
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 4096 times.
31488 if(s_version < 20) // October 2008
7760 {
7761
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divineprotection)
7762 {
7763 16 tempitem.wpn6=wDIVINEPROTECTION2A;
7764 16 tempitem.wpn7=wDIVINEPROTECTION2B;
7765 16 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7766 16 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7767 16 tempitem.wpn5 = iwDivineProtectionShieldFront;
7768 16 tempitem.wpn10 = iwDivineProtectionShieldBack;
7769 16 }
7770 4096 }
7771
7772
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 4096 times.
31488 if(s_version < 21) // November 2008
7773 {
7774
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(tempitem.flags & 0x0100) // ITEM_SLASH
7775 {
7776 tempitem.flags &= ~0x0100;
7777
7778 if(tempitem.family == itype_sword ||
7779 tempitem.family == itype_wand ||
7780 tempitem.family == itype_candle ||
7781 tempitem.family == itype_cbyrna)
7782 {
7783 tempitem.flags |= ITEM_FLAG4;
7784 }
7785 }
7786 4096 }
7787
7788
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 4096 times.
31488 if(s_version < 22) // September 2009
7789 {
7790
4/4
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4064 times.
4096 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7791 {
7792 32 tempitem.misc3 = tempitem.power/2;
7793 32 }
7794 4096 }
7795
7796
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 4096 times.
31488 if(s_version < 23) // March 2011
7797 {
7798
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_divinefire)
7799 16 tempitem.wpn5 = wFIRE;
7800
2/2
✓ Branch 0 taken 4064 times.
✓ Branch 1 taken 16 times.
4080 else if(tempitem.family == itype_book)
7801 16 tempitem.wpn2 = wFIRE;
7802 4096 }
7803
7804 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7805 // whether it was or not, and a lot of existing quests depended on the
7806 // incorrect behavior.
7807
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 4096 times.
31488 if(s_version < 25) // January 2012
7808 {
7809
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 64 times.
4096 if(tempitem.family == itype_bombbag)
7810 64 tempitem.flags |= 16;
7811
7812
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divinefire)
7813 16 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7814 4096 }
7815
7816
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 23808 times.
31488 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7817 {
7818
60/60
✓ Branch 0 taken 7811 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 274 times.
✓ Branch 3 taken 222 times.
✓ Branch 4 taken 138 times.
✓ Branch 5 taken 93 times.
✓ Branch 6 taken 184 times.
✓ Branch 7 taken 183 times.
✓ Branch 8 taken 107 times.
✓ Branch 9 taken 302 times.
✓ Branch 10 taken 276 times.
✓ Branch 11 taken 183 times.
✓ Branch 12 taken 283 times.
✓ Branch 13 taken 184 times.
✓ Branch 14 taken 92 times.
✓ Branch 15 taken 184 times.
✓ Branch 16 taken 107 times.
✓ Branch 17 taken 92 times.
✓ Branch 18 taken 279 times.
✓ Branch 19 taken 93 times.
✓ Branch 20 taken 94 times.
✓ Branch 21 taken 184 times.
✓ Branch 22 taken 92 times.
✓ Branch 23 taken 93 times.
✓ Branch 24 taken 92 times.
✓ Branch 25 taken 92 times.
✓ Branch 26 taken 92 times.
✓ Branch 27 taken 107 times.
✓ Branch 28 taken 92 times.
✓ Branch 29 taken 93 times.
✓ Branch 30 taken 92 times.
✓ Branch 31 taken 93 times.
✓ Branch 32 taken 184 times.
✓ Branch 33 taken 368 times.
✓ Branch 34 taken 94 times.
✓ Branch 35 taken 92 times.
✓ Branch 36 taken 168 times.
✓ Branch 37 taken 368 times.
✓ Branch 38 taken 92 times.
✓ Branch 39 taken 92 times.
✓ Branch 40 taken 92 times.
✓ Branch 41 taken 92 times.
✓ Branch 42 taken 92 times.
✓ Branch 43 taken 185 times.
✓ Branch 44 taken 184 times.
✓ Branch 45 taken 92 times.
✓ Branch 46 taken 277 times.
✓ Branch 47 taken 278 times.
✓ Branch 48 taken 372 times.
✓ Branch 49 taken 92 times.
✓ Branch 50 taken 92 times.
✓ Branch 51 taken 92 times.
✓ Branch 52 taken 92 times.
✓ Branch 53 taken 92 times.
✓ Branch 54 taken 93 times.
✓ Branch 55 taken 2541 times.
✓ Branch 56 taken 983 times.
✓ Branch 57 taken 277 times.
✓ Branch 58 taken 1135 times.
✓ Branch 59 taken 2617 times.
23808 switch(tempitem.family)
7819 {
7820 case itype_sword:
7821 {
7822 7811 tempitem.flags &= ~(ITEM_FLAG5);
7823 7811 tempitem.misc3 = 0;
7824 7811 tempitem.misc4 = 0;
7825 7811 tempitem.misc5 = 0;
7826 7811 tempitem.misc6 = 0;
7827 7811 tempitem.misc7 = 0;
7828 7811 tempitem.misc8 = 0;
7829 7811 tempitem.misc9 = 0;
7830 7811 tempitem.misc10 = 0;
7831 7811 tempitem.wpn4 = 0;
7832 7811 tempitem.wpn5 = 0;
7833 7811 tempitem.wpn6 = 0;
7834 7811 tempitem.wpn7 = 0;
7835 7811 tempitem.wpn8 = 0;
7836 7811 tempitem.wpn9 = 0;
7837 7811 tempitem.wpn10 = 0;
7838 7811 break;
7839 }
7840 case itype_brang:
7841 {
7842 277 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7843 277 tempitem.misc2 = 0;
7844 277 tempitem.misc5 = 0;
7845 277 tempitem.misc6 = 0;
7846 277 tempitem.misc7 = 0;
7847 277 tempitem.misc8 = 0;
7848 277 tempitem.misc9 = 0;
7849 277 tempitem.misc10 = 0;
7850 277 tempitem.wpn4 = 0;
7851 277 tempitem.wpn5 = 0;
7852 277 tempitem.wpn6 = 0;
7853 277 tempitem.wpn7 = 0;
7854 277 tempitem.wpn8 = 0;
7855 277 tempitem.wpn9 = 0;
7856 277 tempitem.wpn10 = 0;
7857 277 break;
7858 }
7859 case itype_arrow:
7860 {
7861 274 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7862 274 tempitem.misc2 = 0;
7863 274 tempitem.misc3 = 0;
7864 274 tempitem.misc4 = 0;
7865 274 tempitem.misc5 = 0;
7866 274 tempitem.misc6 = 0;
7867 274 tempitem.misc7 = 0;
7868 274 tempitem.misc8 = 0;
7869 274 tempitem.misc9 = 0;
7870 274 tempitem.misc10 = 0;
7871 274 tempitem.wpn4 = 0;
7872 274 tempitem.wpn5 = 0;
7873 274 tempitem.wpn6 = 0;
7874 274 tempitem.wpn7 = 0;
7875 274 tempitem.wpn8 = 0;
7876 274 tempitem.wpn9 = 0;
7877 274 tempitem.wpn10 = 0;
7878 274 break;
7879 }
7880 case itype_candle:
7881 {
7882 222 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7883 222 tempitem.misc1 = 0;
7884 222 tempitem.misc2 = 0;
7885 222 tempitem.misc3 = 0;
7886 222 tempitem.misc4 = 0;
7887 222 tempitem.misc5 = 0;
7888 222 tempitem.misc6 = 0;
7889 222 tempitem.misc7 = 0;
7890 222 tempitem.misc8 = 0;
7891 222 tempitem.misc9 = 0;
7892 222 tempitem.misc10 = 0;
7893 222 tempitem.wpn4 = 0;
7894 222 tempitem.wpn5 = 0;
7895 222 tempitem.wpn6 = 0;
7896 222 tempitem.wpn7 = 0;
7897 222 tempitem.wpn8 = 0;
7898 222 tempitem.wpn9 = 0;
7899 222 tempitem.wpn10 = 0;
7900 222 break;
7901 }
7902 case itype_whistle:
7903 {
7904 138 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7905 138 tempitem.misc3 = 0;
7906 138 tempitem.misc4 = 0;
7907 138 tempitem.misc5 = 0;
7908 138 tempitem.misc6 = 0;
7909 138 tempitem.misc7 = 0;
7910 138 tempitem.misc8 = 0;
7911 138 tempitem.misc9 = 0;
7912 138 tempitem.misc10 = 0;
7913 138 tempitem.wpn2 = 0;
7914 138 tempitem.wpn3 = 0;
7915 138 tempitem.wpn4 = 0;
7916 138 tempitem.wpn5 = 0;
7917 138 tempitem.wpn6 = 0;
7918 138 tempitem.wpn7 = 0;
7919 138 tempitem.wpn8 = 0;
7920 138 tempitem.wpn9 = 0;
7921 138 tempitem.wpn10 = 0;
7922 138 break;
7923 }
7924 case itype_bait:
7925 {
7926 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7927 93 tempitem.misc2 = 0;
7928 93 tempitem.misc3 = 0;
7929 93 tempitem.misc4 = 0;
7930 93 tempitem.misc5 = 0;
7931 93 tempitem.misc6 = 0;
7932 93 tempitem.misc7 = 0;
7933 93 tempitem.misc8 = 0;
7934 93 tempitem.misc9 = 0;
7935 93 tempitem.misc10 = 0;
7936 93 tempitem.wpn2 = 0;
7937 93 tempitem.wpn3 = 0;
7938 93 tempitem.wpn4 = 0;
7939 93 tempitem.wpn5 = 0;
7940 93 tempitem.wpn6 = 0;
7941 93 tempitem.wpn7 = 0;
7942 93 tempitem.wpn8 = 0;
7943 93 tempitem.wpn9 = 0;
7944 93 tempitem.wpn10 = 0;
7945 93 break;
7946 }
7947 case itype_letter:
7948 {
7949 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7950 184 tempitem.misc1 = 0;
7951 184 tempitem.misc2 = 0;
7952 184 tempitem.misc3 = 0;
7953 184 tempitem.misc4 = 0;
7954 184 tempitem.misc5 = 0;
7955 184 tempitem.misc6 = 0;
7956 184 tempitem.misc7 = 0;
7957 184 tempitem.misc8 = 0;
7958 184 tempitem.misc9 = 0;
7959 184 tempitem.misc10 = 0;
7960 184 tempitem.wpn = 0;
7961 184 tempitem.wpn2 = 0;
7962 184 tempitem.wpn3 = 0;
7963 184 tempitem.wpn4 = 0;
7964 184 tempitem.wpn5 = 0;
7965 184 tempitem.wpn6 = 0;
7966 184 tempitem.wpn7 = 0;
7967 184 tempitem.wpn8 = 0;
7968 184 tempitem.wpn9 = 0;
7969 184 tempitem.wpn10 = 0;
7970 184 break;
7971 }
7972 case itype_potion:
7973 {
7974 183 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7975 183 tempitem.misc3 = 0;
7976 183 tempitem.misc4 = 0;
7977 183 tempitem.misc5 = 0;
7978 183 tempitem.misc6 = 0;
7979 183 tempitem.misc7 = 0;
7980 183 tempitem.misc8 = 0;
7981 183 tempitem.misc9 = 0;
7982 183 tempitem.misc10 = 0;
7983 183 tempitem.wpn = 0;
7984 183 tempitem.wpn2 = 0;
7985 183 tempitem.wpn3 = 0;
7986 183 tempitem.wpn4 = 0;
7987 183 tempitem.wpn5 = 0;
7988 183 tempitem.wpn6 = 0;
7989 183 tempitem.wpn7 = 0;
7990 183 tempitem.wpn8 = 0;
7991 183 tempitem.wpn9 = 0;
7992 183 tempitem.wpn10 = 0;
7993 183 break;
7994 }
7995 case itype_wand:
7996 {
7997 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
7998 107 tempitem.misc1 = 0;
7999 107 tempitem.misc2 = 0;
8000 107 tempitem.misc3 = 0;
8001 107 tempitem.misc4 = 0;
8002 107 tempitem.misc5 = 0;
8003 107 tempitem.misc6 = 0;
8004 107 tempitem.misc7 = 0;
8005 107 tempitem.misc8 = 0;
8006 107 tempitem.misc9 = 0;
8007 107 tempitem.misc10 = 0;
8008 107 tempitem.wpn4 = 0;
8009 107 tempitem.wpn5 = 0;
8010 107 tempitem.wpn6 = 0;
8011 107 tempitem.wpn7 = 0;
8012 107 tempitem.wpn8 = 0;
8013 107 tempitem.wpn9 = 0;
8014 107 tempitem.wpn10 = 0;
8015 107 break;
8016 }
8017 case itype_ring:
8018 {
8019 302 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8020 302 tempitem.misc2 = 0;
8021 302 tempitem.misc3 = 0;
8022 302 tempitem.misc4 = 0;
8023 302 tempitem.misc5 = 0;
8024 302 tempitem.misc6 = 0;
8025 302 tempitem.misc7 = 0;
8026 302 tempitem.misc8 = 0;
8027 302 tempitem.misc9 = 0;
8028 302 tempitem.misc10 = 0;
8029 302 tempitem.wpn = 0;
8030 302 tempitem.wpn2 = 0;
8031 302 tempitem.wpn3 = 0;
8032 302 tempitem.wpn4 = 0;
8033 302 tempitem.wpn5 = 0;
8034 302 tempitem.wpn6 = 0;
8035 302 tempitem.wpn7 = 0;
8036 302 tempitem.wpn8 = 0;
8037 302 tempitem.wpn9 = 0;
8038 302 tempitem.wpn10 = 0;
8039 302 break;
8040 }
8041 case itype_wallet:
8042 {
8043 276 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8044 276 tempitem.misc3 = 0;
8045 276 tempitem.misc4 = 0;
8046 276 tempitem.misc5 = 0;
8047 276 tempitem.misc6 = 0;
8048 276 tempitem.misc7 = 0;
8049 276 tempitem.misc8 = 0;
8050 276 tempitem.misc9 = 0;
8051 276 tempitem.misc10 = 0;
8052 276 tempitem.wpn = 0;
8053 276 tempitem.wpn2 = 0;
8054 276 tempitem.wpn3 = 0;
8055 276 tempitem.wpn4 = 0;
8056 276 tempitem.wpn5 = 0;
8057 276 tempitem.wpn6 = 0;
8058 276 tempitem.wpn7 = 0;
8059 276 tempitem.wpn8 = 0;
8060 276 tempitem.wpn9 = 0;
8061 276 tempitem.wpn10 = 0;
8062 276 break;
8063 }
8064 case itype_amulet:
8065 {
8066 183 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8067 183 tempitem.misc1 = 0;
8068 183 tempitem.misc2 = 0;
8069 183 tempitem.misc3 = 0;
8070 183 tempitem.misc4 = 0;
8071 183 tempitem.misc5 = 0;
8072 183 tempitem.misc6 = 0;
8073 183 tempitem.misc7 = 0;
8074 183 tempitem.misc8 = 0;
8075 183 tempitem.misc9 = 0;
8076 183 tempitem.misc10 = 0;
8077 183 tempitem.wpn = 0;
8078 183 tempitem.wpn2 = 0;
8079 183 tempitem.wpn3 = 0;
8080 183 tempitem.wpn4 = 0;
8081 183 tempitem.wpn5 = 0;
8082 183 tempitem.wpn6 = 0;
8083 183 tempitem.wpn7 = 0;
8084 183 tempitem.wpn8 = 0;
8085 183 tempitem.wpn9 = 0;
8086 183 tempitem.wpn10 = 0;
8087 183 break;
8088 }
8089 case itype_shield:
8090 {
8091 283 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8092 283 tempitem.misc3 = 0;
8093 283 tempitem.misc4 = 0;
8094 283 tempitem.misc5 = 0;
8095 283 tempitem.misc6 = 0;
8096 283 tempitem.misc7 = 0;
8097 283 tempitem.misc8 = 0;
8098 283 tempitem.misc9 = 0;
8099 283 tempitem.misc10 = 0;
8100 283 tempitem.wpn = 0;
8101 283 tempitem.wpn2 = 0;
8102 283 tempitem.wpn3 = 0;
8103 283 tempitem.wpn4 = 0;
8104 283 tempitem.wpn5 = 0;
8105 283 tempitem.wpn6 = 0;
8106 283 tempitem.wpn7 = 0;
8107 283 tempitem.wpn8 = 0;
8108 283 tempitem.wpn9 = 0;
8109 283 tempitem.wpn10 = 0;
8110 283 break;
8111 }
8112 case itype_bow:
8113 {
8114 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8115 184 tempitem.misc1 = 0;
8116 184 tempitem.misc2 = 0;
8117 184 tempitem.misc3 = 0;
8118 184 tempitem.misc4 = 0;
8119 184 tempitem.misc5 = 0;
8120 184 tempitem.misc6 = 0;
8121 184 tempitem.misc7 = 0;
8122 184 tempitem.misc8 = 0;
8123 184 tempitem.misc9 = 0;
8124 184 tempitem.misc10 = 0;
8125 184 tempitem.wpn = 0;
8126 184 tempitem.wpn2 = 0;
8127 184 tempitem.wpn3 = 0;
8128 184 tempitem.wpn4 = 0;
8129 184 tempitem.wpn5 = 0;
8130 184 tempitem.wpn6 = 0;
8131 184 tempitem.wpn7 = 0;
8132 184 tempitem.wpn8 = 0;
8133 184 tempitem.wpn9 = 0;
8134 184 tempitem.wpn10 = 0;
8135 184 break;
8136 }
8137 case itype_raft:
8138 {
8139 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8140 92 tempitem.misc1 = 0;
8141 92 tempitem.misc2 = 0;
8142 92 tempitem.misc3 = 0;
8143 92 tempitem.misc4 = 0;
8144 92 tempitem.misc5 = 0;
8145 92 tempitem.misc6 = 0;
8146 92 tempitem.misc7 = 0;
8147 92 tempitem.misc8 = 0;
8148 92 tempitem.misc9 = 0;
8149 92 tempitem.misc10 = 0;
8150 92 tempitem.wpn = 0;
8151 92 tempitem.wpn2 = 0;
8152 92 tempitem.wpn3 = 0;
8153 92 tempitem.wpn4 = 0;
8154 92 tempitem.wpn5 = 0;
8155 92 tempitem.wpn6 = 0;
8156 92 tempitem.wpn7 = 0;
8157 92 tempitem.wpn8 = 0;
8158 92 tempitem.wpn9 = 0;
8159 92 tempitem.wpn10 = 0;
8160 92 break;
8161 }
8162 case itype_ladder:
8163 {
8164 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8165 184 tempitem.misc1 = 0;
8166 184 tempitem.misc2 = 0;
8167 184 tempitem.misc3 = 0;
8168 184 tempitem.misc4 = 0;
8169 184 tempitem.misc5 = 0;
8170 184 tempitem.misc6 = 0;
8171 184 tempitem.misc7 = 0;
8172 184 tempitem.misc8 = 0;
8173 184 tempitem.misc9 = 0;
8174 184 tempitem.misc10 = 0;
8175 184 tempitem.wpn = 0;
8176 184 tempitem.wpn2 = 0;
8177 184 tempitem.wpn3 = 0;
8178 184 tempitem.wpn4 = 0;
8179 184 tempitem.wpn5 = 0;
8180 184 tempitem.wpn6 = 0;
8181 184 tempitem.wpn7 = 0;
8182 184 tempitem.wpn8 = 0;
8183 184 tempitem.wpn9 = 0;
8184 184 tempitem.wpn10 = 0;
8185 184 break;
8186 }
8187 case itype_book:
8188 {
8189 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8190 107 tempitem.misc1 = 0;
8191 107 tempitem.misc2 = 0;
8192 107 tempitem.misc3 = 0;
8193 107 tempitem.misc4 = 0;
8194 107 tempitem.misc5 = 0;
8195 107 tempitem.misc6 = 0;
8196 107 tempitem.misc7 = 0;
8197 107 tempitem.misc8 = 0;
8198 107 tempitem.misc9 = 0;
8199 107 tempitem.misc10 = 0;
8200 107 tempitem.wpn3 = 0;
8201 107 tempitem.wpn4 = 0;
8202 107 tempitem.wpn5 = 0;
8203 107 tempitem.wpn6 = 0;
8204 107 tempitem.wpn7 = 0;
8205 107 tempitem.wpn8 = 0;
8206 107 tempitem.wpn9 = 0;
8207 107 tempitem.wpn10 = 0;
8208 107 break;
8209 }
8210 case itype_magickey:
8211 {
8212 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8213 92 tempitem.misc1 = 0;
8214 92 tempitem.misc2 = 0;
8215 92 tempitem.misc3 = 0;
8216 92 tempitem.misc4 = 0;
8217 92 tempitem.misc5 = 0;
8218 92 tempitem.misc6 = 0;
8219 92 tempitem.misc7 = 0;
8220 92 tempitem.misc8 = 0;
8221 92 tempitem.misc9 = 0;
8222 92 tempitem.misc10 = 0;
8223 92 tempitem.wpn = 0;
8224 92 tempitem.wpn2 = 0;
8225 92 tempitem.wpn3 = 0;
8226 92 tempitem.wpn4 = 0;
8227 92 tempitem.wpn5 = 0;
8228 92 tempitem.wpn6 = 0;
8229 92 tempitem.wpn7 = 0;
8230 92 tempitem.wpn8 = 0;
8231 92 tempitem.wpn9 = 0;
8232 92 tempitem.wpn10 = 0;
8233 92 break;
8234 }
8235 case itype_bracelet:
8236 {
8237 279 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8238 279 tempitem.misc1 = 0;
8239 279 tempitem.misc2 = 0;
8240 279 tempitem.misc3 = 0;
8241 279 tempitem.misc4 = 0;
8242 279 tempitem.misc5 = 0;
8243 279 tempitem.misc6 = 0;
8244 279 tempitem.misc7 = 0;
8245 279 tempitem.misc8 = 0;
8246 279 tempitem.misc9 = 0;
8247 279 tempitem.misc10 = 0;
8248 279 tempitem.wpn = 0;
8249 279 tempitem.wpn2 = 0;
8250 279 tempitem.wpn3 = 0;
8251 279 tempitem.wpn4 = 0;
8252 279 tempitem.wpn5 = 0;
8253 279 tempitem.wpn6 = 0;
8254 279 tempitem.wpn7 = 0;
8255 279 tempitem.wpn8 = 0;
8256 279 tempitem.wpn9 = 0;
8257 279 tempitem.wpn10 = 0;
8258 279 break;
8259 }
8260 case itype_flippers:
8261 {
8262 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8263 93 tempitem.misc1 = 0;
8264 93 tempitem.misc2 = 0;
8265 93 tempitem.misc3 = 0;
8266 93 tempitem.misc4 = 0;
8267 93 tempitem.misc5 = 0;
8268 93 tempitem.misc6 = 0;
8269 93 tempitem.misc7 = 0;
8270 93 tempitem.misc8 = 0;
8271 93 tempitem.misc9 = 0;
8272 93 tempitem.misc10 = 0;
8273 93 tempitem.wpn = 0;
8274 93 tempitem.wpn2 = 0;
8275 93 tempitem.wpn3 = 0;
8276 93 tempitem.wpn4 = 0;
8277 93 tempitem.wpn5 = 0;
8278 93 tempitem.wpn6 = 0;
8279 93 tempitem.wpn7 = 0;
8280 93 tempitem.wpn8 = 0;
8281 93 tempitem.wpn9 = 0;
8282 93 tempitem.wpn10 = 0;
8283 93 break;
8284 }
8285 case itype_boots:
8286 {
8287 94 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8288 94 tempitem.misc1 = 0;
8289 94 tempitem.misc2 = 0;
8290 94 tempitem.misc3 = 0;
8291 94 tempitem.misc4 = 0;
8292 94 tempitem.misc5 = 0;
8293 94 tempitem.misc6 = 0;
8294 94 tempitem.misc7 = 0;
8295 94 tempitem.misc8 = 0;
8296 94 tempitem.misc9 = 0;
8297 94 tempitem.misc10 = 0;
8298 94 tempitem.wpn = 0;
8299 94 tempitem.wpn2 = 0;
8300 94 tempitem.wpn3 = 0;
8301 94 tempitem.wpn4 = 0;
8302 94 tempitem.wpn5 = 0;
8303 94 tempitem.wpn6 = 0;
8304 94 tempitem.wpn7 = 0;
8305 94 tempitem.wpn8 = 0;
8306 94 tempitem.wpn9 = 0;
8307 94 tempitem.wpn10 = 0;
8308 94 break;
8309 }
8310 case itype_hookshot:
8311 {
8312 184 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8313 184 tempitem.misc5 = 0;
8314 184 tempitem.misc6 = 0;
8315 184 tempitem.misc7 = 0;
8316 184 tempitem.misc8 = 0;
8317 184 tempitem.misc9 = 0;
8318 184 tempitem.misc10 = 0;
8319 184 tempitem.wpn5 = 0;
8320 184 tempitem.wpn6 = 0;
8321 184 tempitem.wpn7 = 0;
8322 184 tempitem.wpn8 = 0;
8323 184 tempitem.wpn9 = 0;
8324 184 tempitem.wpn10 = 0;
8325 184 break;
8326 }
8327 case itype_lens:
8328 {
8329 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8330 92 tempitem.misc2 = 0;
8331 92 tempitem.misc3 = 0;
8332 92 tempitem.misc4 = 0;
8333 92 tempitem.misc5 = 0;
8334 92 tempitem.misc6 = 0;
8335 92 tempitem.misc7 = 0;
8336 92 tempitem.misc8 = 0;
8337 92 tempitem.misc9 = 0;
8338 92 tempitem.misc10 = 0;
8339 92 tempitem.wpn = 0;
8340 92 tempitem.wpn2 = 0;
8341 92 tempitem.wpn3 = 0;
8342 92 tempitem.wpn4 = 0;
8343 92 tempitem.wpn5 = 0;
8344 92 tempitem.wpn6 = 0;
8345 92 tempitem.wpn7 = 0;
8346 92 tempitem.wpn8 = 0;
8347 92 tempitem.wpn9 = 0;
8348 92 tempitem.wpn10 = 0;
8349 92 break;
8350 }
8351 case itype_hammer:
8352 {
8353 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8354 93 tempitem.misc1 = 0;
8355 93 tempitem.misc2 = 0;
8356 93 tempitem.misc3 = 0;
8357 93 tempitem.misc4 = 0;
8358 93 tempitem.misc5 = 0;
8359 93 tempitem.misc6 = 0;
8360 93 tempitem.misc7 = 0;
8361 93 tempitem.misc8 = 0;
8362 93 tempitem.misc9 = 0;
8363 93 tempitem.misc10 = 0;
8364 93 tempitem.wpn3 = 0;
8365 93 tempitem.wpn4 = 0;
8366 93 tempitem.wpn5 = 0;
8367 93 tempitem.wpn6 = 0;
8368 93 tempitem.wpn7 = 0;
8369 93 tempitem.wpn8 = 0;
8370 93 tempitem.wpn9 = 0;
8371 93 tempitem.wpn10 = 0;
8372 93 break;
8373 }
8374 case itype_divinefire:
8375 {
8376 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8377 92 tempitem.misc3 = 0;
8378 92 tempitem.misc4 = 0;
8379 92 tempitem.misc5 = 0;
8380 92 tempitem.misc6 = 0;
8381 92 tempitem.misc7 = 0;
8382 92 tempitem.misc8 = 0;
8383 92 tempitem.misc9 = 0;
8384 92 tempitem.misc10 = 0;
8385 92 tempitem.wpn6 = 0;
8386 92 tempitem.wpn7 = 0;
8387 92 tempitem.wpn8 = 0;
8388 92 tempitem.wpn9 = 0;
8389 92 tempitem.wpn10 = 0;
8390 92 break;
8391 }
8392 case itype_divineescape:
8393 {
8394 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8395 92 tempitem.misc2 = 0;
8396 92 tempitem.misc3 = 0;
8397 92 tempitem.misc4 = 0;
8398 92 tempitem.misc5 = 0;
8399 92 tempitem.misc6 = 0;
8400 92 tempitem.misc7 = 0;
8401 92 tempitem.misc8 = 0;
8402 92 tempitem.misc9 = 0;
8403 92 tempitem.misc10 = 0;
8404 92 tempitem.wpn = 0;
8405 92 tempitem.wpn2 = 0;
8406 92 tempitem.wpn3 = 0;
8407 92 tempitem.wpn4 = 0;
8408 92 tempitem.wpn5 = 0;
8409 92 tempitem.wpn6 = 0;
8410 92 tempitem.wpn7 = 0;
8411 92 tempitem.wpn8 = 0;
8412 92 tempitem.wpn9 = 0;
8413 92 tempitem.wpn10 = 0;
8414 92 break;
8415 }
8416 case itype_divineprotection:
8417 {
8418 92 tempitem.flags &= ~ (ITEM_FLAG5);
8419 92 tempitem.misc2 = 0;
8420 92 tempitem.misc3 = 0;
8421 92 tempitem.misc4 = 0;
8422 92 tempitem.misc5 = 0;
8423 92 tempitem.misc6 = 0;
8424 92 tempitem.misc7 = 0;
8425 92 tempitem.misc8 = 0;
8426 92 tempitem.misc9 = 0;
8427 92 tempitem.misc10 = 0;
8428 92 break;
8429 }
8430 case itype_bomb:
8431 {
8432 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8433 107 tempitem.misc4 = 0;
8434 107 tempitem.misc5 = 0;
8435 107 tempitem.misc6 = 0;
8436 107 tempitem.misc7 = 0;
8437 107 tempitem.misc8 = 0;
8438 107 tempitem.misc9 = 0;
8439 107 tempitem.misc10 = 0;
8440 107 tempitem.wpn3 = 0;
8441 107 tempitem.wpn4 = 0;
8442 107 tempitem.wpn5 = 0;
8443 107 tempitem.wpn6 = 0;
8444 107 tempitem.wpn7 = 0;
8445 107 tempitem.wpn8 = 0;
8446 107 tempitem.wpn9 = 0;
8447 107 tempitem.wpn10 = 0;
8448 107 break;
8449 }
8450 case itype_sbomb:
8451 {
8452 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8453 92 tempitem.misc4 = 0;
8454 92 tempitem.misc5 = 0;
8455 92 tempitem.misc6 = 0;
8456 92 tempitem.misc7 = 0;
8457 92 tempitem.misc8 = 0;
8458 92 tempitem.misc9 = 0;
8459 92 tempitem.misc10 = 0;
8460 92 tempitem.wpn3 = 0;
8461 92 tempitem.wpn4 = 0;
8462 92 tempitem.wpn5 = 0;
8463 92 tempitem.wpn6 = 0;
8464 92 tempitem.wpn7 = 0;
8465 92 tempitem.wpn8 = 0;
8466 92 tempitem.wpn9 = 0;
8467 92 tempitem.wpn10 = 0;
8468 92 break;
8469 }
8470 case itype_clock:
8471 {
8472 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8473 93 tempitem.misc2 = 0;
8474 93 tempitem.misc3 = 0;
8475 93 tempitem.misc4 = 0;
8476 93 tempitem.misc5 = 0;
8477 93 tempitem.misc6 = 0;
8478 93 tempitem.misc7 = 0;
8479 93 tempitem.misc8 = 0;
8480 93 tempitem.misc9 = 0;
8481 93 tempitem.misc10 = 0;
8482 93 tempitem.wpn = 0;
8483 93 tempitem.wpn2 = 0;
8484 93 tempitem.wpn3 = 0;
8485 93 tempitem.wpn4 = 0;
8486 93 tempitem.wpn5 = 0;
8487 93 tempitem.wpn6 = 0;
8488 93 tempitem.wpn7 = 0;
8489 93 tempitem.wpn8 = 0;
8490 93 tempitem.wpn9 = 0;
8491 93 tempitem.wpn10 = 0;
8492 93 break;
8493 }
8494 case itype_key:
8495 {
8496 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8497 92 tempitem.misc1 = 0;
8498 92 tempitem.misc2 = 0;
8499 92 tempitem.misc3 = 0;
8500 92 tempitem.misc4 = 0;
8501 92 tempitem.misc5 = 0;
8502 92 tempitem.misc6 = 0;
8503 92 tempitem.misc7 = 0;
8504 92 tempitem.misc8 = 0;
8505 92 tempitem.misc9 = 0;
8506 92 tempitem.misc10 = 0;
8507 92 tempitem.wpn = 0;
8508 92 tempitem.wpn2 = 0;
8509 92 tempitem.wpn3 = 0;
8510 92 tempitem.wpn4 = 0;
8511 92 tempitem.wpn5 = 0;
8512 92 tempitem.wpn6 = 0;
8513 92 tempitem.wpn7 = 0;
8514 92 tempitem.wpn8 = 0;
8515 92 tempitem.wpn9 = 0;
8516 92 tempitem.wpn10 = 0;
8517 92 break;
8518 }
8519 case itype_magiccontainer:
8520 {
8521 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8522 93 tempitem.misc1 = 0;
8523 93 tempitem.misc2 = 0;
8524 93 tempitem.misc3 = 0;
8525 93 tempitem.misc4 = 0;
8526 93 tempitem.misc5 = 0;
8527 93 tempitem.misc6 = 0;
8528 93 tempitem.misc7 = 0;
8529 93 tempitem.misc8 = 0;
8530 93 tempitem.misc9 = 0;
8531 93 tempitem.misc10 = 0;
8532 93 tempitem.wpn = 0;
8533 93 tempitem.wpn2 = 0;
8534 93 tempitem.wpn3 = 0;
8535 93 tempitem.wpn4 = 0;
8536 93 tempitem.wpn5 = 0;
8537 93 tempitem.wpn6 = 0;
8538 93 tempitem.wpn7 = 0;
8539 93 tempitem.wpn8 = 0;
8540 93 tempitem.wpn9 = 0;
8541 93 tempitem.wpn10 = 0;
8542 93 break;
8543 }
8544 case itype_triforcepiece:
8545 {
8546 184 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8547 184 tempitem.misc3 = 0;
8548 184 tempitem.misc4 = 0;
8549 184 tempitem.misc5 = 0;
8550 184 tempitem.misc6 = 0;
8551 184 tempitem.misc7 = 0;
8552 184 tempitem.misc8 = 0;
8553 184 tempitem.misc9 = 0;
8554 184 tempitem.misc10 = 0;
8555 184 tempitem.wpn = 0;
8556 184 tempitem.wpn2 = 0;
8557 184 tempitem.wpn3 = 0;
8558 184 tempitem.wpn4 = 0;
8559 184 tempitem.wpn5 = 0;
8560 184 tempitem.wpn6 = 0;
8561 184 tempitem.wpn7 = 0;
8562 184 tempitem.wpn8 = 0;
8563 184 tempitem.wpn9 = 0;
8564 184 tempitem.wpn10 = 0;
8565 184 break;
8566 }
8567 case itype_map: case itype_compass: case itype_bosskey:
8568 {
8569 277 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8570 277 tempitem.misc1 = 0;
8571 277 tempitem.misc2 = 0;
8572 277 tempitem.misc3 = 0;
8573 277 tempitem.misc4 = 0;
8574 277 tempitem.misc5 = 0;
8575 277 tempitem.misc6 = 0;
8576 277 tempitem.misc7 = 0;
8577 277 tempitem.misc8 = 0;
8578 277 tempitem.misc9 = 0;
8579 277 tempitem.misc10 = 0;
8580 277 tempitem.wpn = 0;
8581 277 tempitem.wpn2 = 0;
8582 277 tempitem.wpn3 = 0;
8583 277 tempitem.wpn4 = 0;
8584 277 tempitem.wpn5 = 0;
8585 277 tempitem.wpn6 = 0;
8586 277 tempitem.wpn7 = 0;
8587 277 tempitem.wpn8 = 0;
8588 277 tempitem.wpn9 = 0;
8589 277 tempitem.wpn10 = 0;
8590 277 break;
8591 }
8592 case itype_quiver:
8593 {
8594 368 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8595 368 tempitem.misc3 = 0;
8596 368 tempitem.misc4 = 0;
8597 368 tempitem.misc5 = 0;
8598 368 tempitem.misc6 = 0;
8599 368 tempitem.misc7 = 0;
8600 368 tempitem.misc8 = 0;
8601 368 tempitem.misc9 = 0;
8602 368 tempitem.misc10 = 0;
8603 368 tempitem.wpn = 0;
8604 368 tempitem.wpn2 = 0;
8605 368 tempitem.wpn3 = 0;
8606 368 tempitem.wpn4 = 0;
8607 368 tempitem.wpn5 = 0;
8608 368 tempitem.wpn6 = 0;
8609 368 tempitem.wpn7 = 0;
8610 368 tempitem.wpn8 = 0;
8611 368 tempitem.wpn9 = 0;
8612 368 tempitem.wpn10 = 0;
8613 368 break;
8614 }
8615 case itype_lkey:
8616 {
8617 94 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8618 94 tempitem.misc1 = 0;
8619 94 tempitem.misc2 = 0;
8620 94 tempitem.misc3 = 0;
8621 94 tempitem.misc4 = 0;
8622 94 tempitem.misc5 = 0;
8623 94 tempitem.misc6 = 0;
8624 94 tempitem.misc7 = 0;
8625 94 tempitem.misc8 = 0;
8626 94 tempitem.misc9 = 0;
8627 94 tempitem.misc10 = 0;
8628 94 tempitem.wpn = 0;
8629 94 tempitem.wpn2 = 0;
8630 94 tempitem.wpn3 = 0;
8631 94 tempitem.wpn4 = 0;
8632 94 tempitem.wpn5 = 0;
8633 94 tempitem.wpn6 = 0;
8634 94 tempitem.wpn7 = 0;
8635 94 tempitem.wpn8 = 0;
8636 94 tempitem.wpn9 = 0;
8637 94 tempitem.wpn10 = 0;
8638 94 break;
8639 }
8640 case itype_cbyrna:
8641 {
8642 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8643 92 tempitem.misc4 = 0;
8644 92 tempitem.misc5 = 0;
8645 92 tempitem.misc6 = 0;
8646 92 tempitem.misc7 = 0;
8647 92 tempitem.misc8 = 0;
8648 92 tempitem.misc9 = 0;
8649 92 tempitem.misc10 = 0;
8650 92 tempitem.wpn6 = 0;
8651 92 tempitem.wpn7 = 0;
8652 92 tempitem.wpn8 = 0;
8653 92 tempitem.wpn9 = 0;
8654 92 tempitem.wpn10 = 0;
8655 92 break;
8656 }
8657 case itype_rupee: case itype_arrowammo:
8658 {
8659 1135 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8660 1135 tempitem.misc1 = 0;
8661 1135 tempitem.misc2 = 0;
8662 1135 tempitem.misc3 = 0;
8663 1135 tempitem.misc4 = 0;
8664 1135 tempitem.misc5 = 0;
8665 1135 tempitem.misc6 = 0;
8666 1135 tempitem.misc7 = 0;
8667 1135 tempitem.misc8 = 0;
8668 1135 tempitem.misc9 = 0;
8669 1135 tempitem.misc10 = 0;
8670 1135 tempitem.wpn = 0;
8671 1135 tempitem.wpn2 = 0;
8672 1135 tempitem.wpn3 = 0;
8673 1135 tempitem.wpn4 = 0;
8674 1135 tempitem.wpn5 = 0;
8675 1135 tempitem.wpn6 = 0;
8676 1135 tempitem.wpn7 = 0;
8677 1135 tempitem.wpn8 = 0;
8678 1135 tempitem.wpn9 = 0;
8679 1135 tempitem.wpn10 = 0;
8680 1135 break;
8681 }
8682 case itype_fairy:
8683 {
8684 168 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8685 168 tempitem.misc4 = 0;
8686 168 tempitem.misc5 = 0;
8687 168 tempitem.misc6 = 0;
8688 168 tempitem.misc7 = 0;
8689 168 tempitem.misc8 = 0;
8690 168 tempitem.misc9 = 0;
8691 168 tempitem.misc10 = 0;
8692 168 tempitem.wpn = 0;
8693 168 tempitem.wpn2 = 0;
8694 168 tempitem.wpn3 = 0;
8695 168 tempitem.wpn4 = 0;
8696 168 tempitem.wpn5 = 0;
8697 168 tempitem.wpn6 = 0;
8698 168 tempitem.wpn7 = 0;
8699 168 tempitem.wpn8 = 0;
8700 168 tempitem.wpn9 = 0;
8701 168 tempitem.wpn10 = 0;
8702 168 break;
8703 }
8704 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8705 {
8706 983 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8707 983 tempitem.misc1 = 0;
8708 983 tempitem.misc2 = 0;
8709 983 tempitem.misc3 = 0;
8710 983 tempitem.misc4 = 0;
8711 983 tempitem.misc5 = 0;
8712 983 tempitem.misc6 = 0;
8713 983 tempitem.misc7 = 0;
8714 983 tempitem.misc8 = 0;
8715 983 tempitem.misc9 = 0;
8716 983 tempitem.misc10 = 0;
8717 983 tempitem.wpn = 0;
8718 983 tempitem.wpn2 = 0;
8719 983 tempitem.wpn3 = 0;
8720 983 tempitem.wpn4 = 0;
8721 983 tempitem.wpn5 = 0;
8722 983 tempitem.wpn6 = 0;
8723 983 tempitem.wpn7 = 0;
8724 983 tempitem.wpn8 = 0;
8725 983 tempitem.wpn9 = 0;
8726 983 tempitem.wpn10 = 0;
8727 983 break;
8728 }
8729 case itype_bombbag:
8730 {
8731 368 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8732 368 tempitem.misc3 = 0;
8733 368 tempitem.misc4 = 0;
8734 368 tempitem.misc5 = 0;
8735 368 tempitem.misc6 = 0;
8736 368 tempitem.misc7 = 0;
8737 368 tempitem.misc8 = 0;
8738 368 tempitem.misc9 = 0;
8739 368 tempitem.misc10 = 0;
8740 368 tempitem.wpn = 0;
8741 368 tempitem.wpn2 = 0;
8742 368 tempitem.wpn3 = 0;
8743 368 tempitem.wpn4 = 0;
8744 368 tempitem.wpn5 = 0;
8745 368 tempitem.wpn6 = 0;
8746 368 tempitem.wpn7 = 0;
8747 368 tempitem.wpn8 = 0;
8748 368 tempitem.wpn9 = 0;
8749 368 tempitem.wpn10 = 0;
8750 368 break;
8751 }
8752 case itype_rocs:
8753 {
8754 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8755 92 tempitem.misc1 = 0;
8756 92 tempitem.misc2 = 0;
8757 92 tempitem.misc3 = 0;
8758 92 tempitem.misc4 = 0;
8759 92 tempitem.misc5 = 0;
8760 92 tempitem.misc6 = 0;
8761 92 tempitem.misc7 = 0;
8762 92 tempitem.misc8 = 0;
8763 92 tempitem.misc9 = 0;
8764 92 tempitem.misc10 = 0;
8765 92 tempitem.wpn = 0;
8766 92 tempitem.wpn2 = 0;
8767 92 tempitem.wpn3 = 0;
8768 92 tempitem.wpn4 = 0;
8769 92 tempitem.wpn5 = 0;
8770 92 tempitem.wpn6 = 0;
8771 92 tempitem.wpn7 = 0;
8772 92 tempitem.wpn8 = 0;
8773 92 tempitem.wpn9 = 0;
8774 92 tempitem.wpn10 = 0;
8775 92 break;
8776 }
8777 case itype_hoverboots:
8778 {
8779 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8780 92 tempitem.misc2 = 0;
8781 92 tempitem.misc3 = 0;
8782 92 tempitem.misc4 = 0;
8783 92 tempitem.misc5 = 0;
8784 92 tempitem.misc6 = 0;
8785 92 tempitem.misc7 = 0;
8786 92 tempitem.misc8 = 0;
8787 92 tempitem.misc9 = 0;
8788 92 tempitem.misc10 = 0;
8789 92 tempitem.wpn2 = 0;
8790 92 tempitem.wpn3 = 0;
8791 92 tempitem.wpn4 = 0;
8792 92 tempitem.wpn5 = 0;
8793 92 tempitem.wpn6 = 0;
8794 92 tempitem.wpn7 = 0;
8795 92 tempitem.wpn8 = 0;
8796 92 tempitem.wpn9 = 0;
8797 92 tempitem.wpn10 = 0;
8798 92 break;
8799 }
8800 case itype_spinscroll:
8801 {
8802 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8803 92 tempitem.misc2 = 0;
8804 92 tempitem.misc3 = 0;
8805 92 tempitem.misc4 = 0;
8806 92 tempitem.misc5 = 0;
8807 92 tempitem.misc6 = 0;
8808 92 tempitem.misc7 = 0;
8809 92 tempitem.misc8 = 0;
8810 92 tempitem.misc9 = 0;
8811 92 tempitem.misc10 = 0;
8812 92 tempitem.wpn = 0;
8813 92 tempitem.wpn2 = 0;
8814 92 tempitem.wpn3 = 0;
8815 92 tempitem.wpn4 = 0;
8816 92 tempitem.wpn5 = 0;
8817 92 tempitem.wpn6 = 0;
8818 92 tempitem.wpn7 = 0;
8819 92 tempitem.wpn8 = 0;
8820 92 tempitem.wpn9 = 0;
8821 92 tempitem.wpn10 = 0;
8822 92 break;
8823 }
8824 case itype_crossscroll:
8825 {
8826 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8827 92 tempitem.misc1 = 0;
8828 92 tempitem.misc2 = 0;
8829 92 tempitem.misc3 = 0;
8830 92 tempitem.misc4 = 0;
8831 92 tempitem.misc5 = 0;
8832 92 tempitem.misc6 = 0;
8833 92 tempitem.misc7 = 0;
8834 92 tempitem.misc8 = 0;
8835 92 tempitem.misc9 = 0;
8836 92 tempitem.misc10 = 0;
8837 92 tempitem.wpn = 0;
8838 92 tempitem.wpn2 = 0;
8839 92 tempitem.wpn3 = 0;
8840 92 tempitem.wpn4 = 0;
8841 92 tempitem.wpn5 = 0;
8842 92 tempitem.wpn6 = 0;
8843 92 tempitem.wpn7 = 0;
8844 92 tempitem.wpn8 = 0;
8845 92 tempitem.wpn9 = 0;
8846 92 tempitem.wpn10 = 0;
8847 92 break;
8848 }
8849 case itype_quakescroll:
8850 {
8851 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8852 92 tempitem.misc3 = 0;
8853 92 tempitem.misc4 = 0;
8854 92 tempitem.misc5 = 0;
8855 92 tempitem.misc6 = 0;
8856 92 tempitem.misc7 = 0;
8857 92 tempitem.misc8 = 0;
8858 92 tempitem.misc9 = 0;
8859 92 tempitem.misc10 = 0;
8860 92 tempitem.wpn = 0;
8861 92 tempitem.wpn2 = 0;
8862 92 tempitem.wpn3 = 0;
8863 92 tempitem.wpn4 = 0;
8864 92 tempitem.wpn5 = 0;
8865 92 tempitem.wpn6 = 0;
8866 92 tempitem.wpn7 = 0;
8867 92 tempitem.wpn8 = 0;
8868 92 tempitem.wpn9 = 0;
8869 92 tempitem.wpn10 = 0;
8870 92 break;
8871 }
8872 case itype_whispring:
8873 {
8874 185 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8875 185 tempitem.misc2 = 0;
8876 185 tempitem.misc3 = 0;
8877 185 tempitem.misc4 = 0;
8878 185 tempitem.misc5 = 0;
8879 185 tempitem.misc6 = 0;
8880 185 tempitem.misc7 = 0;
8881 185 tempitem.misc8 = 0;
8882 185 tempitem.misc9 = 0;
8883 185 tempitem.misc10 = 0;
8884 185 tempitem.wpn = 0;
8885 185 tempitem.wpn2 = 0;
8886 185 tempitem.wpn3 = 0;
8887 185 tempitem.wpn4 = 0;
8888 185 tempitem.wpn5 = 0;
8889 185 tempitem.wpn6 = 0;
8890 185 tempitem.wpn7 = 0;
8891 185 tempitem.wpn8 = 0;
8892 185 tempitem.wpn9 = 0;
8893 185 tempitem.wpn10 = 0;
8894 185 break;
8895 }
8896 case itype_chargering:
8897 {
8898 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8899 184 tempitem.misc3 = 0;
8900 184 tempitem.misc4 = 0;
8901 184 tempitem.misc5 = 0;
8902 184 tempitem.misc6 = 0;
8903 184 tempitem.misc7 = 0;
8904 184 tempitem.misc8 = 0;
8905 184 tempitem.misc9 = 0;
8906 184 tempitem.misc10 = 0;
8907 184 tempitem.wpn = 0;
8908 184 tempitem.wpn2 = 0;
8909 184 tempitem.wpn3 = 0;
8910 184 tempitem.wpn4 = 0;
8911 184 tempitem.wpn5 = 0;
8912 184 tempitem.wpn6 = 0;
8913 184 tempitem.wpn7 = 0;
8914 184 tempitem.wpn8 = 0;
8915 184 tempitem.wpn9 = 0;
8916 184 tempitem.wpn10 = 0;
8917 184 break;
8918 }
8919 case itype_perilscroll:
8920 {
8921 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8922 92 tempitem.misc2 = 0;
8923 92 tempitem.misc3 = 0;
8924 92 tempitem.misc4 = 0;
8925 92 tempitem.misc5 = 0;
8926 92 tempitem.misc6 = 0;
8927 92 tempitem.misc7 = 0;
8928 92 tempitem.misc8 = 0;
8929 92 tempitem.misc9 = 0;
8930 92 tempitem.misc10 = 0;
8931 92 tempitem.wpn = 0;
8932 92 tempitem.wpn2 = 0;
8933 92 tempitem.wpn3 = 0;
8934 92 tempitem.wpn4 = 0;
8935 92 tempitem.wpn5 = 0;
8936 92 tempitem.wpn6 = 0;
8937 92 tempitem.wpn7 = 0;
8938 92 tempitem.wpn8 = 0;
8939 92 tempitem.wpn9 = 0;
8940 92 tempitem.wpn10 = 0;
8941 92 break;
8942 }
8943 case itype_wealthmedal:
8944 {
8945 277 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8946 277 tempitem.misc2 = 0;
8947 277 tempitem.misc3 = 0;
8948 277 tempitem.misc4 = 0;
8949 277 tempitem.misc5 = 0;
8950 277 tempitem.misc6 = 0;
8951 277 tempitem.misc7 = 0;
8952 277 tempitem.misc8 = 0;
8953 277 tempitem.misc9 = 0;
8954 277 tempitem.misc10 = 0;
8955 277 tempitem.wpn = 0;
8956 277 tempitem.wpn2 = 0;
8957 277 tempitem.wpn3 = 0;
8958 277 tempitem.wpn4 = 0;
8959 277 tempitem.wpn5 = 0;
8960 277 tempitem.wpn6 = 0;
8961 277 tempitem.wpn7 = 0;
8962 277 tempitem.wpn8 = 0;
8963 277 tempitem.wpn9 = 0;
8964 277 tempitem.wpn10 = 0;
8965 277 break;
8966 }
8967 case itype_heartring:
8968 {
8969 278 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8970 278 tempitem.misc3 = 0;
8971 278 tempitem.misc4 = 0;
8972 278 tempitem.misc5 = 0;
8973 278 tempitem.misc6 = 0;
8974 278 tempitem.misc7 = 0;
8975 278 tempitem.misc8 = 0;
8976 278 tempitem.misc9 = 0;
8977 278 tempitem.misc10 = 0;
8978 278 tempitem.wpn = 0;
8979 278 tempitem.wpn2 = 0;
8980 278 tempitem.wpn3 = 0;
8981 278 tempitem.wpn4 = 0;
8982 278 tempitem.wpn5 = 0;
8983 278 tempitem.wpn6 = 0;
8984 278 tempitem.wpn7 = 0;
8985 278 tempitem.wpn8 = 0;
8986 278 tempitem.wpn9 = 0;
8987 278 tempitem.wpn10 = 0;
8988 278 break;
8989 }
8990 case itype_magicring:
8991 {
8992 372 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8993 372 tempitem.misc3 = 0;
8994 372 tempitem.misc4 = 0;
8995 372 tempitem.misc5 = 0;
8996 372 tempitem.misc6 = 0;
8997 372 tempitem.misc7 = 0;
8998 372 tempitem.misc8 = 0;
8999 372 tempitem.misc9 = 0;
9000 372 tempitem.misc10 = 0;
9001 372 tempitem.wpn = 0;
9002 372 tempitem.wpn2 = 0;
9003 372 tempitem.wpn3 = 0;
9004 372 tempitem.wpn4 = 0;
9005 372 tempitem.wpn5 = 0;
9006 372 tempitem.wpn6 = 0;
9007 372 tempitem.wpn7 = 0;
9008 372 tempitem.wpn8 = 0;
9009 372 tempitem.wpn9 = 0;
9010 372 tempitem.wpn10 = 0;
9011 372 break;
9012 }
9013 case itype_spinscroll2:
9014 {
9015 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9016 92 tempitem.misc2 = 0;
9017 92 tempitem.misc3 = 0;
9018 92 tempitem.misc4 = 0;
9019 92 tempitem.misc5 = 0;
9020 92 tempitem.misc6 = 0;
9021 92 tempitem.misc7 = 0;
9022 92 tempitem.misc8 = 0;
9023 92 tempitem.misc9 = 0;
9024 92 tempitem.misc10 = 0;
9025 92 tempitem.wpn = 0;
9026 92 tempitem.wpn2 = 0;
9027 92 tempitem.wpn3 = 0;
9028 92 tempitem.wpn4 = 0;
9029 92 tempitem.wpn5 = 0;
9030 92 tempitem.wpn6 = 0;
9031 92 tempitem.wpn7 = 0;
9032 92 tempitem.wpn8 = 0;
9033 92 tempitem.wpn9 = 0;
9034 92 tempitem.wpn10 = 0;
9035 92 break;
9036 }
9037 case itype_quakescroll2:
9038 {
9039 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9040 92 tempitem.misc3 = 0;
9041 92 tempitem.misc4 = 0;
9042 92 tempitem.misc5 = 0;
9043 92 tempitem.misc6 = 0;
9044 92 tempitem.misc7 = 0;
9045 92 tempitem.misc8 = 0;
9046 92 tempitem.misc9 = 0;
9047 92 tempitem.misc10 = 0;
9048 92 tempitem.wpn = 0;
9049 92 tempitem.wpn2 = 0;
9050 92 tempitem.wpn3 = 0;
9051 92 tempitem.wpn4 = 0;
9052 92 tempitem.wpn5 = 0;
9053 92 tempitem.wpn6 = 0;
9054 92 tempitem.wpn7 = 0;
9055 92 tempitem.wpn8 = 0;
9056 92 tempitem.wpn9 = 0;
9057 92 tempitem.wpn10 = 0;
9058 92 break;
9059 }
9060 case itype_agony:
9061 {
9062 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9063 92 tempitem.misc2 = 0;
9064 92 tempitem.misc3 = 0;
9065 92 tempitem.misc4 = 0;
9066 92 tempitem.misc5 = 0;
9067 92 tempitem.misc6 = 0;
9068 92 tempitem.misc7 = 0;
9069 92 tempitem.misc8 = 0;
9070 92 tempitem.misc9 = 0;
9071 92 tempitem.misc10 = 0;
9072 92 tempitem.wpn = 0;
9073 92 tempitem.wpn2 = 0;
9074 92 tempitem.wpn3 = 0;
9075 92 tempitem.wpn4 = 0;
9076 92 tempitem.wpn5 = 0;
9077 92 tempitem.wpn6 = 0;
9078 92 tempitem.wpn7 = 0;
9079 92 tempitem.wpn8 = 0;
9080 92 tempitem.wpn9 = 0;
9081 92 tempitem.wpn10 = 0;
9082 92 break;
9083 }
9084 case itype_stompboots:
9085 {
9086 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9087 92 tempitem.misc1 = 0;
9088 92 tempitem.misc2 = 0;
9089 92 tempitem.misc3 = 0;
9090 92 tempitem.misc4 = 0;
9091 92 tempitem.misc5 = 0;
9092 92 tempitem.misc6 = 0;
9093 92 tempitem.misc7 = 0;
9094 92 tempitem.misc8 = 0;
9095 92 tempitem.misc9 = 0;
9096 92 tempitem.misc10 = 0;
9097 92 tempitem.wpn = 0;
9098 92 tempitem.wpn2 = 0;
9099 92 tempitem.wpn3 = 0;
9100 92 tempitem.wpn4 = 0;
9101 92 tempitem.wpn5 = 0;
9102 92 tempitem.wpn6 = 0;
9103 92 tempitem.wpn7 = 0;
9104 92 tempitem.wpn8 = 0;
9105 92 tempitem.wpn9 = 0;
9106 92 tempitem.wpn10 = 0;
9107 92 break;
9108 }
9109 case itype_whimsicalring:
9110 {
9111 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9112 92 tempitem.misc2 = 0;
9113 92 tempitem.misc3 = 0;
9114 92 tempitem.misc4 = 0;
9115 92 tempitem.misc5 = 0;
9116 92 tempitem.misc6 = 0;
9117 92 tempitem.misc7 = 0;
9118 92 tempitem.misc8 = 0;
9119 92 tempitem.misc9 = 0;
9120 92 tempitem.misc10 = 0;
9121 92 tempitem.wpn = 0;
9122 92 tempitem.wpn2 = 0;
9123 92 tempitem.wpn3 = 0;
9124 92 tempitem.wpn4 = 0;
9125 92 tempitem.wpn5 = 0;
9126 92 tempitem.wpn6 = 0;
9127 92 tempitem.wpn7 = 0;
9128 92 tempitem.wpn8 = 0;
9129 92 tempitem.wpn9 = 0;
9130 92 tempitem.wpn10 = 0;
9131 92 break;
9132 }
9133 case itype_perilring:
9134 {
9135 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9136 93 tempitem.misc2 = 0;
9137 93 tempitem.misc3 = 0;
9138 93 tempitem.misc4 = 0;
9139 93 tempitem.misc5 = 0;
9140 93 tempitem.misc6 = 0;
9141 93 tempitem.misc7 = 0;
9142 93 tempitem.misc8 = 0;
9143 93 tempitem.misc9 = 0;
9144 93 tempitem.misc10 = 0;
9145 93 tempitem.wpn = 0;
9146 93 tempitem.wpn2 = 0;
9147 93 tempitem.wpn3 = 0;
9148 93 tempitem.wpn4 = 0;
9149 93 tempitem.wpn5 = 0;
9150 93 tempitem.wpn6 = 0;
9151 93 tempitem.wpn7 = 0;
9152 93 tempitem.wpn8 = 0;
9153 93 tempitem.wpn9 = 0;
9154 93 tempitem.wpn10 = 0;
9155 93 break;
9156 }
9157 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9158 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9159 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9160 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9161 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9162 {
9163 2541 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9164 2541 tempitem.misc1 = 0;
9165 2541 tempitem.misc2 = 0;
9166 2541 tempitem.misc3 = 0;
9167 2541 tempitem.misc4 = 0;
9168 2541 tempitem.misc5 = 0;
9169 2541 tempitem.misc6 = 0;
9170 2541 tempitem.misc7 = 0;
9171 2541 tempitem.misc8 = 0;
9172 2541 tempitem.misc9 = 0;
9173 2541 tempitem.misc10 = 0;
9174 2541 tempitem.wpn = 0;
9175 2541 tempitem.wpn2 = 0;
9176 2541 tempitem.wpn3 = 0;
9177 2541 tempitem.wpn4 = 0;
9178 2541 tempitem.wpn5 = 0;
9179 2541 tempitem.wpn6 = 0;
9180 2541 tempitem.wpn7 = 0;
9181 2541 tempitem.wpn8 = 0;
9182 2541 tempitem.wpn9 = 0;
9183 2541 tempitem.wpn10 = 0;
9184 2541 break;
9185 }
9186 }
9187 23808 }
9188 //Port quest rules to items
9189
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 23808 times.
31488 if( s_version <= 31)
9190 {
9191
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23701 times.
23808 if(tempitem.family == itype_bomb)
9192 {
9193
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 90 times.
107 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9194 90 else tempitem.flags &= ~ ITEM_FLAG2;
9195 107 }
9196
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23609 times.
23701 else if(tempitem.family == itype_sbomb)
9197 {
9198
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 75 times.
92 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9199 75 else tempitem.flags &= ~ ITEM_FLAG2;
9200 92 }
9201
9202
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 23332 times.
23609 else if(tempitem.family == itype_brang)
9203 {
9204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 277 times.
277 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9205 277 else tempitem.flags &= ~ ITEM_FLAG4;
9206 277 }
9207
2/2
✓ Branch 0 taken 23225 times.
✓ Branch 1 taken 107 times.
23332 else if(tempitem.family == itype_wand)
9208 {
9209
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 105 times.
107 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9210 105 else tempitem.flags &= ~ ITEM_FLAG3;
9211 107 }
9212 23808 }
9213
9214 //Port quest rules to items
9215
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 23808 times.
31488 if( s_version <= 37)
9216 {
9217
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 23715 times.
23808 if(tempitem.family == itype_flippers)
9218 {
9219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9220 93 else tempitem.flags &= ~ ITEM_FLAG1;
9221 93 }
9222
2/2
✓ Branch 0 taken 15904 times.
✓ Branch 1 taken 7811 times.
23715 else if(tempitem.family == itype_sword)
9223 {
9224
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9225 7742 else tempitem.flags &= ~ ITEM_FLAG5;
9226 7811 }
9227
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 15797 times.
15904 else if(tempitem.family == itype_wand)
9228 {
9229
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 104 times.
107 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9230 104 else tempitem.flags &= ~ ITEM_FLAG5;
9231 107 }
9232
4/4
✓ Branch 0 taken 15690 times.
✓ Branch 1 taken 107 times.
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 15468 times.
15797 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9233 {
9234 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9235
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 257 times.
329 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9236 257 else tempitem.flags &= ~ ITEM_FLAG3;
9237 329 }
9238 23808 }
9239
9240
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 23808 times.
31488 if( s_version < 38)
9241 {
9242
4/4
✓ Branch 0 taken 23531 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 23347 times.
23808 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9243 {
9244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9245 461 else tempitem.flags &= ~ITEM_FLAG4;
9246
9247
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 450 times.
461 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9248 450 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9249 461 }
9250
2/2
✓ Branch 0 taken 23073 times.
✓ Branch 1 taken 274 times.
23347 else if(tempitem.family == itype_arrow)
9251 {
9252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274 times.
274 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9253 274 else tempitem.flags &= ~ITEM_FLAG4;
9254
9255
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 270 times.
274 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9256 270 else tempitem.flags |= ITEM_FLAG2;
9257 274 }
9258 23808 }
9259
9260
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 23808 times.
31488 if( s_version < 39)
9261 {
9262
6/6
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 23609 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 222 times.
✓ Branch 5 taken 23387 times.
23808 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9263 {
9264
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 409 times.
421 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9265 409 else tempitem.flags &= ~ITEM_FLAG5;
9266 421 }
9267
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 23204 times.
23387 else if(tempitem.family == itype_potion)
9268 {
9269
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 159 times.
183 if(get_qr(qr_NONBUBBLEMEDICINE))
9270 {
9271 24 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9272 24 }
9273 else
9274 {
9275 159 tempitem.flags |= ITEM_FLAG3;
9276
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 74 times.
159 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9277 74 else tempitem.flags &= ~ITEM_FLAG4;
9278 }
9279 183 }
9280
2/2
✓ Branch 0 taken 23020 times.
✓ Branch 1 taken 184 times.
23204 else if(tempitem.family == itype_triforcepiece)
9281 {
9282
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 154 times.
184 if(get_qr(qr_NONBUBBLETRIFORCE))
9283 {
9284 30 tempitem.flags |= ITEM_FLAG3;
9285
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 24 times.
30 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9286 24 else tempitem.flags &= ~ITEM_FLAG4;
9287 30 }
9288 else
9289 {
9290 154 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9291 }
9292 184 }
9293 23808 }
9294
9295
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 23808 times.
31488 if( s_version < 40)
9296 {
9297
4/4
✓ Branch 0 taken 23506 times.
✓ Branch 1 taken 302 times.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 23413 times.
23808 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9298 {
9299
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 348 times.
395 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9300 348 else tempitem.flags &= ~ITEM_FLAG1;
9301 395 }
9302
8/8
✓ Branch 0 taken 23191 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 15380 times.
✓ Branch 3 taken 7811 times.
✓ Branch 4 taken 15273 times.
✓ Branch 5 taken 107 times.
✓ Branch 6 taken 92 times.
✓ Branch 7 taken 15181 times.
23413 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9303 {
9304
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 8151 times.
8232 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9305 8151 else tempitem.flags &= ~ITEM_FLAG8;
9306 8232 }
9307
6/6
✓ Branch 0 taken 15997 times.
✓ Branch 1 taken 7811 times.
✓ Branch 2 taken 15890 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 93 times.
✓ Branch 5 taken 15797 times.
23808 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9308 {
9309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9310 8011 else tempitem.flags &= ~ITEM_FLAG7;
9311 8011 }
9312
2/2
✓ Branch 0 taken 15705 times.
✓ Branch 1 taken 92 times.
15797 else if(tempitem.family == itype_cbyrna)
9313 {
9314 92 tempitem.flags |= ITEM_FLAG7;
9315 92 }
9316 23808 }
9317
9318
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 23808 times.
31488 if( s_version < 41 )
9319 {
9320
2/2
✓ Branch 0 taken 15997 times.
✓ Branch 1 taken 7811 times.
23808 if(tempitem.family == itype_sword)
9321 {
9322
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9323 7742 else tempitem.flags &= ~ITEM_FLAG9;
9324
9325
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9326 7742 else tempitem.flags &= ~ITEM_FLAG10;
9327 7811 }
9328 23808 }
9329
9330
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 23808 times.
31488 if( s_version < 42 )
9331 {
9332
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23701 times.
23808 if(tempitem.family == itype_wand)
9333 {
9334
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 105 times.
107 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9335 105 else tempitem.flags &= ~ITEM_FLAG3;
9336
9337 107 tempitem.flags &= ~ITEM_FLAG6;
9338 107 }
9339
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 23608 times.
23701 else if(tempitem.family == itype_hammer)
9340 {
9341 93 tempitem.flags &= ~ITEM_FLAG3;
9342 93 }
9343
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23516 times.
23608 else if(tempitem.family == itype_cbyrna)
9344 {
9345 92 tempitem.flags |= ITEM_FLAG3;
9346
9347 92 tempitem.flags &= ~ITEM_FLAG6;
9348 92 }
9349
2/2
✓ Branch 0 taken 15705 times.
✓ Branch 1 taken 7811 times.
23516 else if(tempitem.family == itype_sword)
9350 {
9351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7811 times.
7811 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9352 7811 else tempitem.flags &= ~ITEM_FLAG6;
9353 7811 }
9354 23808 }
9355
9356
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 23808 times.
31488 if( s_version < 43 )
9357 {
9358
2/2
✓ Branch 0 taken 23670 times.
✓ Branch 1 taken 138 times.
23808 if(tempitem.family == itype_whistle)
9359 {
9360
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 135 times.
138 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9361 135 else tempitem.flags &= ~ITEM_FLAG3;
9362 138 }
9363 23808 }
9364
9365
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 23808 times.
31488 if( s_version < 45 )
9366 {
9367
2/2
✓ Branch 0 taken 23715 times.
✓ Branch 1 taken 93 times.
23808 if(tempitem.family == itype_flippers)
9368 {
9369 93 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9370 93 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9371 93 }
9372 23808 }
9373
9374
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 23808 times.
31488 if( s_version < 46 )
9375 {
9376
2/2
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
23808 if(tempitem.family == itype_raft)
9377 {
9378 92 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9379 92 }
9380 23808 }
9381
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 23808 times.
31488 if ( s_version < 34 ) //! set the default counter for older quests.
9382 {
9383
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 23733 times.
23808 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9384 {
9385 75 tempitem.cost_counter[0] = 1;
9386 75 }
9387 else
9388 {
9389
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 19125 times.
23733 if(get_qr(qr_ENABLEMAGIC))
9390 4608 tempitem.cost_counter[0] = 4;
9391 else
9392 {
9393 19125 tempitem.cost_amount[0] = 0;
9394 19125 tempitem.cost_counter[0] = -1;
9395 }
9396 }
9397 23808 }
9398
9399
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 23808 times.
31488 if ( s_version < 35 ) //new Lens of Truth flags
9400 {
9401
2/2
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
23808 if ( tempitem.family == itype_lens )
9402 {
9403
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 3 times.
92 if ( get_qr(qr_RAFTLENS) )
9404 {
9405 3 tempitem.flags |= ITEM_FLAG4;
9406 3 }
9407
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 52 times.
92 if ( get_qr(qr_LENSHINTS) )
9408 {
9409 52 tempitem.flags |= ITEM_FLAG1;
9410 52 }
9411
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 4 times.
92 if ( get_qr(qr_LENSSEESENEMIES) )
9412 {
9413 4 tempitem.flags |= ITEM_FLAG5;
9414 4 }
9415 92 }
9416 23808 }
9417
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 23808 times.
31488 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9418 {
9419
2/2
✓ Branch 0 taken 190464 times.
✓ Branch 1 taken 23808 times.
214272 for ( int32_t q = 0; q < 8; q++ )
9420 {
9421 190464 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9422 190464 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9423 190464 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9424 190464 tempitem.sprite_initiald[q] = 0;
9425 190464 }
9426
2/2
✓ Branch 0 taken 47616 times.
✓ Branch 1 taken 23808 times.
71424 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9427 23808 tempitem.sprite_script = 0;
9428 23808 }
9429
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 23808 times.
31488 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9430 {
9431 23808 tempitem.pickupflag = 0;
9432 23808 }
9433
9434
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 23808 times.
31488 if( s_version < 51 )
9435 {
9436
2/2
✓ Branch 0 taken 23586 times.
✓ Branch 1 taken 222 times.
23808 if( tempitem.family == itype_candle )
9437 {
9438 222 tempitem.misc4 = 50; //Step speed
9439 222 }
9440 23808 }
9441
9442
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 23808 times.
31488 if( s_version < 52 )
9443 {
9444
2/2
✓ Branch 0 taken 23525 times.
✓ Branch 1 taken 283 times.
23808 if( tempitem.family == itype_shield )
9445 283 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9446 23808 }
9447
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 23808 times.
31488 if(s_version < 53)
9448 {
9449
4/4
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23335 times.
✓ Branch 2 taken 274 times.
✓ Branch 3 taken 92 times.
23808 switch(tempitem.family)
9450 {
9451 case itype_arrow:
9452 274 tempitem.cost_counter[1] = crARROWS;
9453 274 tempitem.cost_amount[1] = 1;
9454 274 break;
9455 case itype_bomb:
9456 107 tempitem.cost_counter[1] = crBOMBS;
9457 107 tempitem.cost_amount[1] = 1;
9458 107 break;
9459 case itype_sbomb:
9460 92 tempitem.cost_counter[1] = crSBOMBS;
9461 92 tempitem.cost_amount[1] = 1;
9462 92 break;
9463 default:
9464 23335 tempitem.cost_counter[1] = crNONE;
9465 23335 tempitem.cost_amount[1] = 0;
9466 23335 }
9467 23808 tempitem.magiccosttimer[1] = 0;
9468 23808 }
9469
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25088 times.
31488 if( s_version < 54 )
9470 {
9471
2/2
✓ Branch 0 taken 24989 times.
✓ Branch 1 taken 99 times.
25088 if( tempitem.family == itype_flippers )
9472 99 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9473 25088 }
9474
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25088 times.
31488 if(s_version < 55)
9475 {
9476
3/3
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 24700 times.
25088 switch(tempitem.family)
9477 {
9478 case itype_spinscroll:
9479 case itype_quakescroll:
9480 194 tempitem.usesound2 = WAV_ZN1CHARGE;
9481 194 break;
9482 case itype_spinscroll2:
9483 case itype_quakescroll2:
9484 194 tempitem.usesound2 = WAV_ZN1CHARGE2;
9485 194 break;
9486 }
9487 25088 }
9488
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25088 times.
31488 if(s_version < 56)
9489 {
9490
4/4
✓ Branch 0 taken 24645 times.
✓ Branch 1 taken 97 times.
✓ Branch 2 taken 234 times.
✓ Branch 3 taken 112 times.
25088 switch(tempitem.family)
9491 {
9492 case itype_divinefire:
9493
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 5 times.
97 SETFLAG(tempitem.flags, ITEM_FLAG9, version < 0x255); //Strong Fire
9494
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 81 times.
97 SETFLAG(tempitem.flags, ITEM_FLAG10, version < 0x250); //Magic Fire
9495 97 tempitem.flags |= ITEM_FLAG11; //Divine Fire
9496 97 break;
9497 case itype_candle:
9498
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 120 times.
234 SETFLAG(tempitem.flags, ITEM_FLAG9, tempitem.fam_type > 1); //Strong Fire
9499 234 tempitem.flags &= ~ITEM_FLAG10; //Magic Fire
9500 234 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9501 234 break;
9502 case itype_book:
9503 112 tempitem.flags |= ITEM_FLAG9; //Strong Fire
9504 112 tempitem.flags |= ITEM_FLAG10; //Magic Fire
9505 112 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9506 112 break;
9507 }
9508 25088 }
9509
9510
2/2
✓ Branch 0 taken 29344 times.
✓ Branch 1 taken 2144 times.
31488 if(tempitem.fam_type==0) // Always do this
9511 2144 tempitem.fam_type=1;
9512
9513 31488 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9514 31488 }
9515
9516 123 return 0;
9517 123 }
9518
9519 static bool did_init_def_items = false;
9520 63168 void init_def_items()
9521 {
9522
2/2
✓ Branch 0 taken 63128 times.
✓ Branch 1 taken 40 times.
63168 if(did_init_def_items) return;
9523 40 did_init_def_items = true;
9524 40 default_items[3].cost_counter[1] = crBOMBS;
9525 40 default_items[13].cost_counter[1] = crARROWS;
9526 40 default_items[14].cost_counter[1] = crARROWS;
9527 40 default_items[48].cost_counter[1] = crSBOMBS;
9528 40 default_items[57].cost_counter[1] = crARROWS;
9529 63168 }
9530 63168 void reset_itembuf(itemdata *item, int32_t id)
9531 {
9532 63168 init_def_items();
9533
2/2
✓ Branch 0 taken 26894 times.
✓ Branch 1 taken 36274 times.
63168 if(id<iLast)
9534 {
9535 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9536 36274 word tile = item->tile;
9537 36274 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9538 36274 int32_t ltm = item->ltm;
9539
9540 36274 memcpy(item,&default_items[id],sizeof(itemdata));
9541 36274 item->tile = tile;
9542 36274 item->misc_flags = miscs;
9543 36274 item->csets = cset;
9544 36274 item->frames = frames;
9545 36274 item->speed = speed;
9546 36274 item->delay = delay;
9547 36274 item->ltm = ltm;
9548 36274 }
9549 63168 }
9550
9551 14336 void reset_itemname(int32_t id)
9552 {
9553 14336 sprintf(item_string[id],"zz%03d",id);
9554
9555
2/2
✓ Branch 0 taken 6328 times.
✓ Branch 1 taken 8008 times.
14336 if(id < iLast)
9556 8008 strcpy(item_string[id],old_item_string[id]);
9557 14336 }
9558
9559 123 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9560 {
9561 123 word weapons_to_read=MAXWPNS;
9562 int32_t dummy;
9563 byte padding;
9564 wpndata tempweapon;
9565 123 word s_version=0, s_cversion=0;
9566
9567
9568
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(Header->zelda_version < 0x186)
9569 {
9570 weapons_to_read=64;
9571 }
9572
9573
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(Header->zelda_version < 0x185)
9574 {
9575 weapons_to_read=32;
9576 }
9577
9578
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 119 times.
123 if(Header->zelda_version > 0x192)
9579 {
9580 119 weapons_to_read=0;
9581
9582 //section version info
9583
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&s_version,f))
9584 {
9585 return qe_invalid;
9586 }
9587
9588 119 FFCore.quest_format[vWeaponSprites] = s_version;
9589
9590 //al_trace("Weapons version %d\n", s_version);
9591
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&s_cversion,f))
9592 {
9593 return qe_invalid;
9594 }
9595
9596 //section size
9597
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetl(&dummy,f))
9598 {
9599 return qe_invalid;
9600 }
9601
9602 //finally... section data
9603
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&weapons_to_read,f))
9604 {
9605 return qe_invalid;
9606 }
9607
9608
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if (!(weapons_to_read >= 0 && weapons_to_read <= MAXWPNS))
9609 {
9610 return qe_invalid;
9611 }
9612 119 }
9613
9614
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if(s_version>2)
9615 {
9616
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 107 times.
27499 for(int32_t i=0; i<weapons_to_read; i++)
9617 {
9618 char tempname[64];
9619
9620
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if(!pfread(tempname, 64, f))
9621 {
9622 return qe_invalid;
9623 }
9624
9625 27392 weapon_string[i][0] = '\0';
9626 27392 strncat(weapon_string[i], tempname, 64 - 1);
9627 27392 }
9628
9629
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(s_version<4)
9630 {
9631 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9632 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9633 }
9634
9635
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(s_version<5)
9636 {
9637 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9638 }
9639
9640 /*
9641 if (s_version<6)
9642 {
9643 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9644 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9645 }
9646 */
9647 107 }
9648 else
9649 {
9650
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXWPNS; i++)
9651 4096 reset_weaponname(i);
9652 }
9653
9654
2/2
✓ Branch 0 taken 29232 times.
✓ Branch 1 taken 123 times.
29355 for(int32_t i=0; i<weapons_to_read; i++)
9655 {
9656 29232 word oldtile = 0;
9657
2/2
✓ Branch 0 taken 7168 times.
✓ Branch 1 taken 22064 times.
29232 if (s_version < 8)
9658 {
9659
1/2
✓ Branch 0 taken 22064 times.
✗ Branch 1 not taken.
22064 if (!p_igetw(&oldtile, f))
9660 return qe_invalid;
9661 22064 }
9662
9663
1/2
✓ Branch 0 taken 29232 times.
✗ Branch 1 not taken.
29232 if(!p_getc(&tempweapon.misc,f))
9664 {
9665 return qe_invalid;
9666 }
9667
9668
1/2
✓ Branch 0 taken 29232 times.
✗ Branch 1 not taken.
29232 if(!p_getc(&tempweapon.csets,f))
9669 {
9670 return qe_invalid;
9671 }
9672
9673
1/2
✓ Branch 0 taken 29232 times.
✗ Branch 1 not taken.
29232 if(!p_getc(&tempweapon.frames,f))
9674 {
9675 return qe_invalid;
9676 }
9677
9678
1/2
✓ Branch 0 taken 29232 times.
✗ Branch 1 not taken.
29232 if(!p_getc(&tempweapon.speed,f))
9679 {
9680 return qe_invalid;
9681 }
9682
9683
1/2
✓ Branch 0 taken 29232 times.
✗ Branch 1 not taken.
29232 if(!p_getc(&tempweapon.type,f))
9684 {
9685 return qe_invalid;
9686 }
9687
9688
2/2
✓ Branch 0 taken 21552 times.
✓ Branch 1 taken 7680 times.
29232 if ( s_version >= 7 )
9689 {
9690
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetw(&tempweapon.script,f))
9691 {
9692 return qe_invalid;
9693 }
9694
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempweapon.tile,f))
9695 {
9696 return qe_invalid;
9697 }
9698 7680 }
9699
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 21552 times.
29232 if ( s_version < 7 )
9700 {
9701 21552 tempweapon.tile = oldtile;
9702 21552 }
9703
9704
2/2
✓ Branch 0 taken 28208 times.
✓ Branch 1 taken 1024 times.
29232 if(Header->zelda_version < 0x193)
9705 {
9706
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f))
9707 {
9708 return qe_invalid;
9709 }
9710 1024 }
9711
9712
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 1840 times.
29232 if(s_version < 6)
9713 {
9714
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1836 times.
1840 if(i==ewFIRETRAIL)
9715 {
9716 4 tempweapon.misc |= WF_BEHIND;
9717 4 }
9718 else
9719 1836 tempweapon.misc &= ~WF_BEHIND;
9720 1840 }
9721
9722 29232 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9723 29232 }
9724
9725
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if(s_version<2)
9726 {
9727 16 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9728 16 }
9729
9730
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if(s_version<5)
9731 {
9732 16 wpnsbuf[iwQuarterHearts].tile=1;
9733 16 wpnsbuf[iwQuarterHearts].csets=1;
9734 16 }
9735
9736
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(Header->zelda_version < 0x176)
9737 {
9738 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9739 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9740 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9741 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9742 }
9743
9744
2/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
123 if((Header->zelda_version < 0x192)||
9745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9746 {
9747 4 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9748 4 }
9749
9750
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
123 if((Header->zelda_version < 0x210))
9751 {
9752 4 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9753 4 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9754 4 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9755 4 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9756 4 }
9757
9758 123 return 0;
9759 123 }
9760
9761 123 void init_guys(int32_t guyversion)
9762 {
9763
2/2
✓ Branch 0 taken 62976 times.
✓ Branch 1 taken 123 times.
63099 for(int32_t i=0; i<MAXGUYS; i++)
9764 {
9765 62976 guysbuf[i] = default_guys[0];
9766 62976 }
9767
9768
2/2
✓ Branch 0 taken 21771 times.
✓ Branch 1 taken 123 times.
21894 for(int32_t i=0; i<OLDMAXGUYS; i++)
9769 {
9770 21771 guysbuf[i] = default_guys[i];
9771
2/2
✓ Branch 0 taken 21525 times.
✓ Branch 1 taken 246 times.
21771 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9772 21771 guysbuf[i].spr_death = iwDeath;
9773 21771 guysbuf[i].spr_spawn = iwSpawn;
9774 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9775
4/4
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 18939 times.
✓ Branch 2 taken 2816 times.
✓ Branch 3 taken 16 times.
21771 if(guyversion<=3 && i==ePATRABS)
9776 {
9777 16 guysbuf[i].bosspal=spDIG;
9778 16 guysbuf[i].cset=14;
9779 16 guysbuf[i].misc9=14;
9780 16 }
9781
9782
2/2
✓ Branch 0 taken 18939 times.
✓ Branch 1 taken 2832 times.
21771 if(guyversion<=3)
9783 {
9784 // Rope/Ghini Flash rules
9785
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 2124 times.
2832 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9786 {
9787
2/2
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
2124 if(i==eROPE2)
9788 {
9789 12 guysbuf[i].flags2 &= ~guy_flashing;
9790 12 }
9791 2124 }
9792
9793
2/2
✓ Branch 0 taken 2301 times.
✓ Branch 1 taken 531 times.
2832 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9794 {
9795
12/12
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 525 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 519 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 513 times.
531 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9796 {
9797 18 guysbuf[i].flags2 &= ~guy_flashing;
9798 18 }
9799 531 }
9800
9801
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 16 times.
2832 if(i==eGHINI2)
9802 {
9803
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
16 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9804 {
9805 3 guysbuf[i].flags2 |= guy_blinking;
9806 3 }
9807
9808
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9809 {
9810 guysbuf[i].flags2 |= guy_transparent;
9811 }
9812 16 }
9813 2832 }
9814
9815 // Darknut fix
9816
10/10
✓ Branch 0 taken 21648 times.
✓ Branch 1 taken 123 times.
✓ Branch 2 taken 21525 times.
✓ Branch 3 taken 123 times.
✓ Branch 4 taken 21402 times.
✓ Branch 5 taken 123 times.
✓ Branch 6 taken 21279 times.
✓ Branch 7 taken 123 times.
✓ Branch 8 taken 123 times.
✓ Branch 9 taken 21156 times.
21771 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9817 {
9818
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 210 times.
615 if(get_qr(qr_NEWENEMYTILES))
9819 {
9820 405 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9821 405 guysbuf[i].s_width=guysbuf[i].e_width;
9822 405 guysbuf[i].s_height=guysbuf[i].e_height;
9823 405 }
9824 210 else guysbuf[i].s_tile=860;
9825
9826
2/2
✓ Branch 0 taken 535 times.
✓ Branch 1 taken 80 times.
615 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9827 {
9828 80 guysbuf[i].flags |= guy_bkshield;
9829 80 }
9830 615 }
9831
9832
4/4
✓ Branch 0 taken 21648 times.
✓ Branch 1 taken 123 times.
✓ Branch 2 taken 21763 times.
✓ Branch 3 taken 8 times.
21771 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9833 {
9834 8 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9835 8 }
9836 21771 }
9837 123 }
9838
9839 4096 void reset_weaponname(int32_t i)
9840 {
9841
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 2688 times.
4096 if(i<wLast)
9842 {
9843 1408 strcpy(weapon_string[i],old_weapon_string[i]);
9844 1408 }
9845 else
9846 2688 sprintf(weapon_string[i],"zz%03d",i);
9847 4096 }
9848
9849 123 void init_item_drop_sets()
9850 {
9851
2/2
✓ Branch 0 taken 31488 times.
✓ Branch 1 taken 123 times.
31611 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9852 {
9853 // item_drop_sets[i] = default_item_drop_sets[0];
9854 31488 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9855 31488 }
9856
9857
2/2
✓ Branch 0 taken 1599 times.
✓ Branch 1 taken 123 times.
1722 for(int32_t i=0; i<isMAX; i++)
9858 {
9859 1599 item_drop_sets[i] = default_item_drop_sets[i];
9860
9861 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9862
2/2
✓ Branch 0 taken 15990 times.
✓ Branch 1 taken 1599 times.
17589 for(int32_t j=0; j<10; ++j)
9863 {
9864 15990 int32_t it = item_drop_sets[i].item[j];
9865
9866
3/4
✓ Branch 0 taken 11224 times.
✓ Branch 1 taken 4766 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 720 times.
15990 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9867
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 10504 times.
11224 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9868 {
9869 720 item_drop_sets[i].chance[j+1]=0;
9870 720 }
9871
3/4
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 14778 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 492 times.
15270 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9872 {
9873 item_drop_sets[i].chance[j+1]=0;
9874 }
9875
9876 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9877
2/2
✓ Branch 0 taken 15982 times.
✓ Branch 1 taken 8 times.
15990 if(itemsbuf[it].family == itype_misc)
9878 {
9879 // If a non-gameplay item was selected, then item drop was aborted.
9880 // Reflect this by increasing the 'Nothing' chance accordingly.
9881 8 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9882 8 item_drop_sets[i].chance[j+1]=0;
9883 8 }
9884 15990 }
9885 1599 }
9886 123 }
9887
9888 119 void init_favorites()
9889 {
9890
2/2
✓ Branch 0 taken 35700 times.
✓ Branch 1 taken 119 times.
35819 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9891 {
9892 35700 favorite_combos[i]=-1;
9893 35700 }
9894
9895
2/2
✓ Branch 0 taken 35700 times.
✓ Branch 1 taken 119 times.
35819 for(int32_t i=0; i<MAXFAVORITECOMBOALIASES; i++)
9896 {
9897 35700 favorite_comboaliases[i]=-1;
9898 35700 }
9899 119 }
9900
9901 const char *ctype_name[cMAX]=
9902 {
9903 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9904 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9905 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9906 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9907 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9908 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9909 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9910 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9911 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9912 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9913 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9914 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9915 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9916 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9917 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9918 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9919 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9920 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9921 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9922 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9923 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9924 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9925 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9926 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9927 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9928 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9929 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9930 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9931
9932 };
9933
9934 218 int32_t init_combo_classes()
9935 {
9936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
218 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9937
2/2
✓ Branch 0 taken 39458 times.
✓ Branch 1 taken 218 times.
39676 for(int32_t i=0; i<cMAX; i++)
9938 {
9939 39458 combo_class_buf[i] = default_combo_classes[i];
9940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39458 times.
39458 if ( char const* nm = zi->getComboTypeName(i) )
9941 {
9942 39458 size_t len = strlen(nm);
9943
2/2
✓ Branch 0 taken 2525312 times.
✓ Branch 1 taken 39458 times.
2564770 for ( size_t q = 0; q < 64; q++ )
9944 {
9945
2/2
✓ Branch 0 taken 583150 times.
✓ Branch 1 taken 1942162 times.
2525312 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9946 2525312 }
9947 39458 }
9948 39458 }
9949
9950 218 return 0;
9951 }
9952
9953 97 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
9954 {
9955
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 assert(v_herosprites < 6);
9956 //these are here to bypass compiler warnings about unused arguments
9957 97 cv_herosprites=cv_herosprites;
9958
9959 97 zinit.hero_swim_speed=67; //default
9960 97 setupherotiles(zinit.heroAnimationStyle);
9961 97 setupherodefenses();
9962 97 setupherooffsets();
9963
9964
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 77 times.
97 if(v_herosprites>=0)
9965 {
9966 word tile, tile2;
9967 byte flip, extend, dummy_byte;
9968
9969
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
9970 {
9971
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
9972 {
9973 return qe_invalid;
9974 }
9975
9976
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
9977 {
9978 return qe_invalid;
9979 }
9980
9981
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
9982 {
9983 return qe_invalid;
9984 }
9985
9986 308 walkspr[i][spr_tile]=(int32_t)tile;
9987 308 walkspr[i][spr_flip]=(int32_t)flip;
9988 308 walkspr[i][spr_extend]=(int32_t)extend;
9989 308 }
9990
9991
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
9992 {
9993
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
9994 {
9995 return qe_invalid;
9996 }
9997
9998
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
9999 {
10000 return qe_invalid;
10001 }
10002
10003
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10004 {
10005 return qe_invalid;
10006 }
10007
10008 308 stabspr[i][spr_tile]=(int32_t)tile;
10009 308 stabspr[i][spr_flip]=(int32_t)flip;
10010 308 stabspr[i][spr_extend]=(int32_t)extend;
10011 308 }
10012
10013
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10014 {
10015
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10016 {
10017 return qe_invalid;
10018 }
10019
10020
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10021 {
10022 return qe_invalid;
10023 }
10024
10025
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10026 {
10027 return qe_invalid;
10028 }
10029
10030 308 slashspr[i][spr_tile]=(int32_t)tile;
10031 308 slashspr[i][spr_flip]=(int32_t)flip;
10032 308 slashspr[i][spr_extend]=(int32_t)extend;
10033 308 }
10034
10035
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10036 {
10037
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10038 {
10039 return qe_invalid;
10040 }
10041
10042
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10043 {
10044 return qe_invalid;
10045 }
10046
10047
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10048 {
10049 return qe_invalid;
10050 }
10051
10052 308 floatspr[i][spr_tile]=(int32_t)tile;
10053 308 floatspr[i][spr_flip]=(int32_t)flip;
10054 308 floatspr[i][spr_extend]=(int32_t)extend;
10055 308 }
10056
10057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>1)
10058 {
10059
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10060 {
10061
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10062 {
10063 return qe_invalid;
10064 }
10065
10066
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10067 {
10068 return qe_invalid;
10069 }
10070
10071
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10072 {
10073 return qe_invalid;
10074 }
10075
10076 308 swimspr[i][spr_tile]=(int32_t)tile;
10077 308 swimspr[i][spr_flip]=(int32_t)flip;
10078 308 swimspr[i][spr_extend]=(int32_t)extend;
10079 308 }
10080 77 }
10081
10082
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10083 {
10084
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10085 {
10086 return qe_invalid;
10087 }
10088
10089
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10090 {
10091 return qe_invalid;
10092 }
10093
10094
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10095 {
10096 return qe_invalid;
10097 }
10098
10099 308 divespr[i][spr_tile]=(int32_t)tile;
10100 308 divespr[i][spr_flip]=(int32_t)flip;
10101 308 divespr[i][spr_extend]=(int32_t)extend;
10102 308 }
10103
10104
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10105 {
10106
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10107 {
10108 return qe_invalid;
10109 }
10110
10111
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10112 {
10113 return qe_invalid;
10114 }
10115
10116
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10117 {
10118 return qe_invalid;
10119 }
10120
10121 308 poundspr[i][spr_tile]=(int32_t)tile;
10122 308 poundspr[i][spr_flip]=(int32_t)flip;
10123 308 poundspr[i][spr_extend]=(int32_t)extend;
10124 308 }
10125
10126
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&tile,f))
10127 {
10128 return qe_invalid;
10129 }
10130
10131 77 flip=0;
10132
10133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>0)
10134 {
10135
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&flip,f))
10136 {
10137 return qe_invalid;
10138 }
10139 77 }
10140
10141
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&extend,f))
10142 {
10143 return qe_invalid;
10144 }
10145
10146 77 castingspr[spr_tile]=(int32_t)tile;
10147 77 castingspr[spr_flip]=(int32_t)flip;
10148 77 castingspr[spr_extend]=(int32_t)extend;
10149
10150
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(v_herosprites>0)
10151 {
10152 77 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10153
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 77 times.
231 for(int32_t i=0; i<2; i++)
10154 {
10155
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 154 times.
462 for(int32_t j=0; j<num_holdsprs; j++)
10156 {
10157
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10158 {
10159 return qe_invalid;
10160 }
10161
10162
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10163 {
10164 return qe_invalid;
10165 }
10166
10167
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10168 {
10169 return qe_invalid;
10170 }
10171
10172 308 holdspr[i][j][spr_tile]=(int32_t)tile;
10173 308 holdspr[i][j][spr_flip]=(int32_t)flip;
10174 308 holdspr[i][j][spr_extend]=(int32_t)extend;
10175 308 }
10176 154 }
10177 77 }
10178 else
10179 {
10180 for(int32_t i=0; i<2; i++)
10181 {
10182 if(!p_igetw(&tile,f))
10183 {
10184 return qe_invalid;
10185 }
10186
10187 if(!p_igetw(&tile2,f))
10188 {
10189 return qe_invalid;
10190 }
10191
10192 if(!p_getc(&extend,f))
10193 {
10194 return qe_invalid;
10195 }
10196
10197 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10198 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10199 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10200 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10201 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10202 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10203 }
10204 }
10205
10206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>2)
10207 {
10208
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10209 {
10210
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10211 {
10212 return qe_invalid;
10213 }
10214
10215
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10216 {
10217 return qe_invalid;
10218 }
10219
10220
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10221 {
10222 return qe_invalid;
10223 }
10224
10225 308 jumpspr[i][spr_tile]=(int32_t)tile;
10226 308 jumpspr[i][spr_flip]=(int32_t)flip;
10227 308 jumpspr[i][spr_extend]=(int32_t)extend;
10228 308 }
10229 77 }
10230
10231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>3)
10232 {
10233
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10234 {
10235
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10236 {
10237 return qe_invalid;
10238 }
10239
10240
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10241 {
10242 return qe_invalid;
10243 }
10244
10245
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10246 {
10247 return qe_invalid;
10248 }
10249
10250 308 chargespr[i][spr_tile]=(int32_t)tile;
10251 308 chargespr[i][spr_flip]=(int32_t)flip;
10252 308 chargespr[i][spr_extend]=(int32_t)extend;
10253 308 }
10254 77 }
10255
10256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>4)
10257 {
10258
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&dummy_byte,f))
10259 {
10260 return qe_invalid;
10261 }
10262
10263 77 zinit.hero_swim_speed=(byte)dummy_byte;
10264 77 }
10265
10266 77 memset(frozenspr, 0, sizeof(frozenspr));
10267 77 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10268 77 memset(onfirespr, 0, sizeof(onfirespr));
10269 77 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10270 77 memset(diggingspr, 0, sizeof(diggingspr));
10271 77 memset(usingrodspr, 0, sizeof(usingrodspr));
10272 77 memset(usingcanespr, 0, sizeof(usingcanespr));
10273 77 memset(pushingspr, 0, sizeof(pushingspr));
10274 77 memset(liftingspr, 0, sizeof(liftingspr));
10275 77 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10276 77 memset(stunnedspr, 0, sizeof(stunnedspr));
10277 77 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10278 77 memset(fallingspr, 0, sizeof(fallingspr));
10279 77 memset(shockedspr, 0, sizeof(shockedspr));
10280 77 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10281 77 memset(pullswordspr, 0, sizeof(pullswordspr));
10282 77 memset(readingspr, 0, sizeof(readingspr));
10283 77 memset(slash180spr, 0, sizeof(slash180spr));
10284 77 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10285 77 memset(dashspr, 0, sizeof(dashspr));
10286 77 memset(bonkspr, 0, sizeof(bonkspr));
10287 77 memset(medallionsprs, 0, sizeof(medallionsprs));
10288 77 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10289 77 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10290
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t q = 0; q < 4; ++q)
10291 {
10292
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 308 times.
1232 for(int32_t p = 0; p < 3; ++p)
10293 {
10294 924 drowningspr[q][p] = divespr[q][p];
10295 924 drowning_lavaspr[q][p] = divespr[q][p];
10296 924 }
10297 308 }
10298 77 memset(sideswimspr, 0, sizeof(sideswimspr));
10299 77 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10300 77 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10301 77 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10302 77 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10303 77 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10304 77 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10305 77 }
10306
10307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(FFCore.quest_format[vInitData] < 34)
10308 {
10309 97 bool fastswim = zinit.hero_swim_speed > 60;
10310 // '2/3' or '1/2'
10311 97 zinit.hero_swim_mult = fastswim ? 2 : 1;
10312 97 zinit.hero_swim_div = fastswim ? 3 : 2;
10313 97 }
10314 97 return 0;
10315 97 }
10316
10317 5100 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10318 {
10319 5100 arr[spr_tile] = tile;
10320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5100 times.
5100 arr[spr_flip] = (flip > 3 ? 0 : flip);
10321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5100 times.
5100 arr[spr_extend] = (ext > 2 ? 0 : ext);
10322 5100 }
10323 //Used to read the player sprites as int32_t, not word.
10324 30 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
10325 {
10326 //these are here to bypass compiler warnings about unused arguments
10327 30 cv_herosprites=cv_herosprites;
10328
10329 30 zinit.hero_swim_speed=67; //default
10330 30 setupherotiles(zinit.heroAnimationStyle);
10331 30 setupherodefenses();
10332 30 setupherooffsets();
10333
10334 int32_t tile, tile2;
10335 byte flip, extend, dummy_byte;
10336
10337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(v_herosprites>=0)
10338 {
10339
10340
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t i=0; i<4; i++)
10341 {
10342
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10343 {
10344 return qe_invalid;
10345 }
10346
10347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
10348 {
10349 return qe_invalid;
10350 }
10351
10352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10353 {
10354 return qe_invalid;
10355 }
10356
10357 120 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10358 120 }
10359
10360
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t i=0; i<4; i++)
10361 {
10362
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10363 {
10364 return qe_invalid;
10365 }
10366
10367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
10368 {
10369 return qe_invalid;
10370 }
10371
10372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10373 {
10374 return qe_invalid;
10375 }
10376
10377 120 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10378 120 }
10379
10380
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t i=0; i<4; i++)
10381 {
10382
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10383 {
10384 return qe_invalid;
10385 }
10386
10387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
10388 {
10389 return qe_invalid;
10390 }
10391
10392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10393 {
10394 return qe_invalid;
10395 }
10396
10397 120 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10398 120 }
10399
10400
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t i=0; i<4; i++)
10401 {
10402
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10403 {
10404 return qe_invalid;
10405 }
10406
10407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
10408 {
10409 return qe_invalid;
10410 }
10411
10412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10413 {
10414 return qe_invalid;
10415 }
10416
10417 120 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10418 120 }
10419
10420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(v_herosprites>1)
10421 {
10422
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t i=0; i<4; i++)
10423 {
10424
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10425 {
10426 return qe_invalid;
10427 }
10428
10429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
10430 {
10431 return qe_invalid;
10432 }
10433
10434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10435 {
10436 return qe_invalid;
10437 }
10438
10439 120 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10440 120 }
10441 30 }
10442
10443
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t i=0; i<4; i++)
10444 {
10445
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10446 {
10447 return qe_invalid;
10448 }
10449
10450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
10451 {
10452 return qe_invalid;
10453 }
10454
10455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10456 {
10457 return qe_invalid;
10458 }
10459
10460 120 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10461 120 }
10462
10463
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t i=0; i<4; i++)
10464 {
10465
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10466 {
10467 return qe_invalid;
10468 }
10469
10470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
10471 {
10472 return qe_invalid;
10473 }
10474
10475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10476 {
10477 return qe_invalid;
10478 }
10479
10480 120 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10481 120 }
10482
10483
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tile,f))
10484 {
10485 return qe_invalid;
10486 }
10487
10488 30 flip=0;
10489
10490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(v_herosprites>0)
10491 {
10492
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&flip,f))
10493 {
10494 return qe_invalid;
10495 }
10496 30 }
10497
10498
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&extend,f))
10499 {
10500 return qe_invalid;
10501 }
10502
10503 30 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10504
10505
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(v_herosprites>0)
10506 {
10507 30 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10508
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 30 times.
90 for(int32_t i=0; i<2; i++)
10509 {
10510
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 60 times.
240 for(int32_t j=0; j<num_holdsprs; j++)
10511 {
10512
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!p_igetl(&tile,f))
10513 {
10514 return qe_invalid;
10515 }
10516
10517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if(!p_getc(&flip,f))
10518 {
10519 return qe_invalid;
10520 }
10521
10522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if(!p_getc(&extend,f))
10523 {
10524 return qe_invalid;
10525 }
10526
10527 180 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10528 180 }
10529 60 }
10530 30 }
10531 else
10532 {
10533 for(int32_t i=0; i<2; i++)
10534 {
10535 if(!p_igetl(&tile,f))
10536 {
10537 return qe_invalid;
10538 }
10539
10540 if(!p_igetl(&tile2,f))
10541 {
10542 return qe_invalid;
10543 }
10544
10545 if(!p_getc(&extend,f))
10546 {
10547 return qe_invalid;
10548 }
10549
10550 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10551 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10552 }
10553 }
10554
10555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(v_herosprites>2)
10556 {
10557
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t i=0; i<4; i++)
10558 {
10559
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10560 {
10561 return qe_invalid;
10562 }
10563
10564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
10565 {
10566 return qe_invalid;
10567 }
10568
10569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10570 {
10571 return qe_invalid;
10572 }
10573
10574 120 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10575 120 }
10576 30 }
10577
10578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(v_herosprites>3)
10579 {
10580
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t i=0; i<4; i++)
10581 {
10582
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10583 {
10584 return qe_invalid;
10585 }
10586
10587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
10588 {
10589 return qe_invalid;
10590 }
10591
10592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10593 {
10594 return qe_invalid;
10595 }
10596
10597 120 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10598 120 }
10599 30 }
10600
10601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(v_herosprites>4)
10602 {
10603
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&dummy_byte,f))
10604 {
10605 return qe_invalid;
10606 }
10607
10608 30 zinit.hero_swim_speed=(byte)dummy_byte;
10609 30 }
10610
10611
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(v_herosprites>6)
10612 {
10613
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10614 {
10615
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10616 return qe_invalid;
10617
10618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
10619 return qe_invalid;
10620
10621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10622 return qe_invalid;
10623
10624 120 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10625 120 }
10626
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10627 {
10628
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10629 return qe_invalid;
10630
10631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
10632 return qe_invalid;
10633
10634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10635 return qe_invalid;
10636
10637 120 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10638 120 }
10639
10640
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10641 {
10642
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10643 return qe_invalid;
10644
10645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
10646 return qe_invalid;
10647
10648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10649 return qe_invalid;
10650
10651 120 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10652 120 }
10653
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10654 {
10655
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10656 return qe_invalid;
10657
10658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
10659 return qe_invalid;
10660
10661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10662 return qe_invalid;
10663
10664 120 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10665 120 }
10666
10667
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10668 {
10669
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10670 return qe_invalid;
10671
10672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
10673 return qe_invalid;
10674
10675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10676 return qe_invalid;
10677
10678 120 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10679 120 }
10680
10681
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10682 {
10683
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10684 return qe_invalid;
10685
10686
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f))
10687 return qe_invalid;
10688
10689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10690 return qe_invalid;
10691
10692 120 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10693 120 }
10694
10695
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10696 {
10697
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10698 return qe_invalid;
10699
10700
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f))
10701 return qe_invalid;
10702
10703
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f))
10704 return qe_invalid;
10705
10706 120 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10707 120 }
10708
10709
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10710 {
10711
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10712 return qe_invalid;
10713
10714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
10715 return qe_invalid;
10716
10717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10718 return qe_invalid;
10719
10720 120 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10721 120 }
10722
10723
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10724 {
10725
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10726 return qe_invalid;
10727
10728
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f))
10729 return qe_invalid;
10730
10731
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f))
10732 return qe_invalid;
10733
10734 120 byte frames = 0;
10735
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 112 times.
120 if(v_herosprites > 15)
10736 {
10737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(!p_getc(&frames,f))
10738 return qe_invalid;
10739 112 }
10740
10741 120 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10742 120 liftingspr[q][spr_frames] = frames;
10743 120 }
10744
10745
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10746 {
10747
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10748 return qe_invalid;
10749
10750
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f))
10751 return qe_invalid;
10752
10753
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f))
10754 return qe_invalid;
10755
10756 120 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10757 120 }
10758
10759
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10760 {
10761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_igetl(&tile,f))
10762 return qe_invalid;
10763
10764
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f))
10765 return qe_invalid;
10766
10767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10768 return qe_invalid;
10769
10770 120 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10771 120 }
10772
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10773 {
10774
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10775 return qe_invalid;
10776
10777
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f))
10778 return qe_invalid;
10779
10780
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f))
10781 return qe_invalid;
10782
10783 120 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10784 120 }
10785
10786
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10787 {
10788
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10789 return qe_invalid;
10790
10791
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f))
10792 return qe_invalid;
10793
10794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10795 return qe_invalid;
10796
10797 120 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10798 120 }
10799
10800
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10801 {
10802
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10803 return qe_invalid;
10804
10805
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f))
10806 return qe_invalid;
10807
10808
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f))
10809 return qe_invalid;
10810
10811 120 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10812 120 }
10813
10814
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10815 {
10816
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10817 return qe_invalid;
10818
10819
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f))
10820 return qe_invalid;
10821
10822
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f))
10823 return qe_invalid;
10824
10825 120 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10826 120 }
10827
10828
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10829 {
10830
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10831 return qe_invalid;
10832
10833
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f))
10834 return qe_invalid;
10835
10836
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f))
10837 return qe_invalid;
10838
10839 120 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10840 120 }
10841
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10842 {
10843
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10844 return qe_invalid;
10845
10846
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f))
10847 return qe_invalid;
10848
10849
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f))
10850 return qe_invalid;
10851
10852 120 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10853 120 }
10854
10855
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10856 {
10857
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10858 return qe_invalid;
10859
10860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
10861 return qe_invalid;
10862
10863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10864 return qe_invalid;
10865
10866 120 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10867 120 }
10868
10869
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10870 {
10871
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10872 return qe_invalid;
10873
10874
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f))
10875 return qe_invalid;
10876
10877
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f))
10878 return qe_invalid;
10879
10880 120 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10881 120 }
10882
10883
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10884 {
10885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_igetl(&tile,f))
10886 return qe_invalid;
10887
10888
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f))
10889 return qe_invalid;
10890
10891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10892 return qe_invalid;
10893
10894 120 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10895 120 }
10896
10897
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10898 {
10899
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10900 return qe_invalid;
10901
10902
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f))
10903 return qe_invalid;
10904
10905
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f))
10906 return qe_invalid;
10907
10908 120 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10909 120 }
10910
10911
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10912 {
10913
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10914 return qe_invalid;
10915
10916
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f))
10917 return qe_invalid;
10918
10919
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f))
10920 return qe_invalid;
10921
10922 120 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10923 120 }
10924
10925
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10926 {
10927
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10928 return qe_invalid;
10929
10930
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f))
10931 return qe_invalid;
10932
10933
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f))
10934 return qe_invalid;
10935
10936 120 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10937 120 }
10938
10939
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 30 times.
120 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10940 {
10941
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(!p_igetl(&tile,f))
10942 return qe_invalid;
10943
10944
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(!p_getc(&flip,f))
10945 return qe_invalid;
10946
10947
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(!p_getc(&extend,f))
10948 return qe_invalid;
10949
10950 90 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10951 90 }
10952 30 }
10953 else
10954 {
10955 memset(frozenspr, 0, sizeof(frozenspr));
10956 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10957 memset(onfirespr, 0, sizeof(onfirespr));
10958 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10959 memset(diggingspr, 0, sizeof(diggingspr));
10960 memset(usingrodspr, 0, sizeof(usingrodspr));
10961 memset(usingcanespr, 0, sizeof(usingcanespr));
10962 memset(pushingspr, 0, sizeof(pushingspr));
10963 memset(liftingspr, 0, sizeof(liftingspr));
10964 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10965 memset(stunnedspr, 0, sizeof(stunnedspr));
10966 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10967 memset(fallingspr, 0, sizeof(fallingspr));
10968 memset(shockedspr, 0, sizeof(shockedspr));
10969 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10970 memset(pullswordspr, 0, sizeof(pullswordspr));
10971 memset(readingspr, 0, sizeof(readingspr));
10972 memset(slash180spr, 0, sizeof(slash180spr));
10973 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10974 memset(dashspr, 0, sizeof(dashspr));
10975 memset(bonkspr, 0, sizeof(bonkspr));
10976 memset(medallionsprs, 0, sizeof(medallionsprs));
10977 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10978 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10979 for(int32_t q = 0; q < 4; ++q)
10980 {
10981 for(int32_t p = 0; p < 3; ++p)
10982 {
10983 drowningspr[q][p] = divespr[q][p];
10984 drowning_lavaspr[q][p] = divespr[q][p];
10985 }
10986 }
10987 }
10988
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (v_herosprites > 8)
10989 {
10990
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10991 {
10992
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
10993 return qe_invalid;
10994
10995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
10996 return qe_invalid;
10997
10998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
10999 return qe_invalid;
11000
11001 120 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11002 120 }
11003 30 }
11004 else
11005 {
11006 memset(sideswimspr, 0, sizeof(sideswimspr));
11007 }
11008
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (v_herosprites > 9)
11009 {
11010
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11011 {
11012
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
11013 return qe_invalid;
11014
11015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
11016 return qe_invalid;
11017
11018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
11019 return qe_invalid;
11020
11021 120 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11022 120 }
11023
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11024 {
11025
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
11026 return qe_invalid;
11027
11028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
11029 return qe_invalid;
11030
11031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
11032 return qe_invalid;
11033
11034 120 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11035 120 }
11036
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11037 {
11038
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
11039 return qe_invalid;
11040
11041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
11042 return qe_invalid;
11043
11044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
11045 return qe_invalid;
11046
11047 120 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11048 120 }
11049
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11050 {
11051
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
11052 return qe_invalid;
11053
11054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
11055 return qe_invalid;
11056
11057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
11058 return qe_invalid;
11059
11060 120 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11061 120 }
11062 30 }
11063 else
11064 {
11065 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11066 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11067 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11068 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11069 }
11070
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (v_herosprites > 10)
11071 {
11072
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11073 {
11074 int32_t hmr;
11075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_igetl(&hmr,f))
11076 return qe_invalid;
11077
11078 120 hammeroffsets[q] = hmr;
11079 120 }
11080 30 }
11081 else
11082 {
11083 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11084 }
11085
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (v_herosprites > 11)
11086 {
11087
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 30 times.
120 for(int32_t q = 0; q < 3; ++q)
11088 {
11089
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(!p_igetl(&tile,f))
11090 return qe_invalid;
11091
11092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
90 if(!p_getc(&flip,f))
11093 return qe_invalid;
11094
11095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
90 if(!p_getc(&extend,f))
11096 return qe_invalid;
11097
11098 90 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11099 90 }
11100 30 }
11101 else
11102 {
11103 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11104 }
11105
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (v_herosprites > 12)
11106 {
11107
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tile,f))
11108 return qe_invalid;
11109
11110
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&flip,f))
11111 return qe_invalid;
11112
11113
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&extend,f))
11114 return qe_invalid;
11115 30 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11116
11117 30 }
11118 else
11119 {
11120 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11121 }
11122
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (v_herosprites > 13)
11123 {
11124
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11125 {
11126
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
11127 return qe_invalid;
11128
11129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
11130 return qe_invalid;
11131
11132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
11133 return qe_invalid;
11134
11135 120 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11136 120 }
11137 30 }
11138 else
11139 {
11140 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11141 }
11142
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (v_herosprites > 14)
11143 {
11144
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11145 {
11146
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f))
11147 return qe_invalid;
11148
11149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f))
11150 return qe_invalid;
11151
11152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f))
11153 return qe_invalid;
11154
11155 120 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11156 120 }
11157 30 }
11158 else
11159 {
11160 memset(revslashspr, 0, sizeof(revslashspr));
11161 }
11162
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (v_herosprites > 7)
11163 {
11164 30 int32_t num_defense = wMax;
11165 30 byte def = 0;
11166
11167 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11168 /*if(v_herosprites > [x])
11169 * {
11170 * num_defense = 146 //value of wMax on version 8
11171 * }
11172 */
11173
11174
2/2
✓ Branch 0 taken 4380 times.
✓ Branch 1 taken 30 times.
4410 for (int32_t q = 0; q < num_defense; q++)
11175 {
11176
1/2
✓ Branch 0 taken 4380 times.
✗ Branch 1 not taken.
4380 if (!p_getc(&def, f))
11177 return qe_invalid;
11178
11179 4380 hero_defence[q] = def;
11180 4380 }
11181 30 }
11182 else
11183 {
11184 int32_t num_defense = wMax;
11185 for (int32_t q = 0; q < num_defense; q++)
11186 {
11187 hero_defence[q] = 0;
11188 }
11189 }
11190 30 }
11191
11192
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 5 times.
30 if(FFCore.quest_format[vInitData] < 34)
11193 {
11194 5 bool fastswim = zinit.hero_swim_speed > 60;
11195 // '2/3' or '1/2'
11196 5 zinit.hero_swim_mult = fastswim ? 2 : 1;
11197 5 zinit.hero_swim_div = fastswim ? 3 : 2;
11198 5 }
11199 30 return 0;
11200 30 }
11201
11202
11203 107 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11204 {
11205 //these are here to bypass compiler warnings about unused arguments
11206 107 Header=Header;
11207
11208 dword dummy;
11209 107 word s_version=0, s_cversion=0;
11210
11211 //section version info
11212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(!p_igetw(&s_version,f))
11213 {
11214 return qe_invalid;
11215 }
11216
11217 107 FFCore.quest_format[vHeroSprites] = s_version;
11218
11219 //al_trace("Player sprites version %d\n", s_version);
11220
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetw(&s_cversion,f))
11221 {
11222 return qe_invalid;
11223 }
11224
11225 //section size
11226
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetl(&dummy,f))
11227 {
11228 return qe_invalid;
11229 }
11230
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 77 times.
107 if ( s_version >= 6 )
11231 {
11232 //al_trace("Reading Player Sprites v6\n");
11233 30 return readherosprites3(f, s_version, dummy);
11234 }
11235 77 else return readherosprites2(f, s_version, dummy);
11236 107 }
11237
11238 107 int32_t readsubscreens(PACKFILE *f, zquestheader *Header)
11239 {
11240 int32_t dummy;
11241 107 word s_version=0, s_cversion=0;
11242
11243 //section version info
11244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(!p_igetw(&s_version,f))
11245 {
11246 return qe_invalid;
11247 }
11248
11249 107 FFCore.quest_format[vSubscreen] = s_version;
11250
11251 //al_trace("Subscreens version %d\n", s_version);
11252
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetw(&s_cversion,f))
11253 {
11254 return qe_invalid;
11255 }
11256
11257 //section size
11258
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetl(&dummy,f))
11259 {
11260 return qe_invalid;
11261 }
11262
11263 //finally... section data
11264
2/2
✓ Branch 0 taken 13696 times.
✓ Branch 1 taken 107 times.
13803 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11265 {
11266 13696 int32_t ret = read_one_subscreen(f, Header, i, s_version, s_cversion);
11267
11268
1/2
✓ Branch 0 taken 13696 times.
✗ Branch 1 not taken.
13696 if(ret!=0) return ret;
11269 13696 }
11270
11271 107 return 0;
11272 107 }
11273
11274 13696 int32_t read_one_subscreen(PACKFILE *f, zquestheader *, int32_t i, word s_version, word)
11275 {
11276 13696 int32_t numsub=0;
11277 13696 byte temp_ss=0;
11278 subscreen_object temp_sub_stack;
11279 13696 subscreen_object *temp_sub = &temp_sub_stack;
11280
11281 char tempname[64];
11282
11283 // FWIW I never saw anything bigger than 20.
11284 #define MAX_DP1_LEN 1024
11285 char tempdp1[MAX_DP1_LEN];
11286
11287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13696 times.
13696 if(!pfread(tempname,64,f))
11288 {
11289 return qe_invalid;
11290 }
11291
11292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13696 times.
13696 if(s_version > 1)
11293 {
11294
1/2
✓ Branch 0 taken 13696 times.
✗ Branch 1 not taken.
13696 if(!p_getc(&temp_ss,f))
11295 {
11296 return qe_invalid;
11297 }
11298 13696 }
11299
11300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13696 times.
13696 if(s_version < 4)
11301 {
11302 uint8_t tmp=0;
11303
11304 if(!p_getc(&tmp,f))
11305 {
11306 return qe_invalid;
11307 }
11308
11309 numsub = (int32_t)tmp;
11310 }
11311 else
11312 {
11313 word tmp;
11314
11315
1/2
✓ Branch 0 taken 13696 times.
✗ Branch 1 not taken.
13696 if(!p_igetw(&tmp, f))
11316 {
11317 return qe_invalid;
11318 }
11319
11320 13696 numsub = (int32_t)tmp;
11321 }
11322
11323 int32_t j;
11324
11325
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38342 times.
✓ Branch 2 taken 24646 times.
✓ Branch 3 taken 13696 times.
38342 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11326 {
11327 24646 memset(temp_sub,0,sizeof(subscreen_object));
11328
11329
2/2
✓ Branch 0 taken 1214 times.
✓ Branch 1 taken 23432 times.
24646 switch(custom_subscreen[i].objects[j].type)
11330 {
11331 case ssoTEXT:
11332 case ssoTEXTBOX:
11333 case ssoCURRENTITEMTEXT:
11334 case ssoCURRENTITEMCLASSTEXT:
11335
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1214 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1214 times.
1214 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11336
11337 //fall through
11338 default:
11339 24646 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11340 24646 break;
11341 }
11342
11343
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_getc(&(temp_sub->type),f))
11344 {
11345 return qe_invalid;
11346 }
11347
11348
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_getc(&(temp_sub->pos),f))
11349 {
11350 return qe_invalid;
11351 }
11352
11353
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(s_version < 5)
11354 {
11355 switch(temp_sub->pos)
11356 {
11357 case 0:
11358 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11359 break;
11360
11361 case 1:
11362 temp_sub->pos = sspUP;
11363 break;
11364
11365 case 2:
11366 temp_sub->pos = sspDOWN;
11367 break;
11368
11369 default:
11370 temp_sub->pos = 0;
11371 }
11372 }
11373
11374
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_igetw(&(temp_sub->x),f))
11375 {
11376 return qe_invalid;
11377 }
11378
11379
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_igetw(&(temp_sub->y),f))
11380 {
11381 return qe_invalid;
11382 }
11383
11384
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_igetw(&(temp_sub->w),f))
11385 {
11386 return qe_invalid;
11387 }
11388
11389
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_igetw(&(temp_sub->h),f))
11390 {
11391 return qe_invalid;
11392 }
11393
11394
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_getc(&(temp_sub->colortype1),f))
11395 {
11396 return qe_invalid;
11397 }
11398
11399
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_igetw(&(temp_sub->color1),f))
11400 {
11401 return qe_invalid;
11402 }
11403
11404
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_getc(&(temp_sub->colortype2),f))
11405 {
11406 return qe_invalid;
11407 }
11408
11409
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_igetw(&(temp_sub->color2),f))
11410 {
11411 return qe_invalid;
11412 }
11413
11414
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_getc(&(temp_sub->colortype3),f))
11415 {
11416 return qe_invalid;
11417 }
11418
11419
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_igetw(&(temp_sub->color3),f))
11420 {
11421 return qe_invalid;
11422 }
11423
11424
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_igetd(&(temp_sub->d1),f))
11425 {
11426 return qe_invalid;
11427 }
11428
11429
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_igetd(&(temp_sub->d2),f))
11430 {
11431 return qe_invalid;
11432 }
11433
11434
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_igetd(&(temp_sub->d3),f))
11435 {
11436 return qe_invalid;
11437 }
11438
11439
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_igetd(&(temp_sub->d4),f))
11440 {
11441 return qe_invalid;
11442 }
11443
11444
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_igetd(&(temp_sub->d5),f))
11445 {
11446 return qe_invalid;
11447 }
11448
11449
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_igetd(&(temp_sub->d6),f))
11450 {
11451 return qe_invalid;
11452 }
11453
11454
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_igetd(&(temp_sub->d7),f))
11455 {
11456 return qe_invalid;
11457 }
11458
11459
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_igetd(&(temp_sub->d8),f))
11460 {
11461 return qe_invalid;
11462 }
11463
11464
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_igetd(&(temp_sub->d9),f))
11465 {
11466 return qe_invalid;
11467 }
11468
11469
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_igetd(&(temp_sub->d10),f))
11470 {
11471 return qe_invalid;
11472 }
11473
11474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24646 times.
24646 if(s_version < 2)
11475 {
11476 if(!p_igetl(&(temp_sub->speed),f))
11477 {
11478 return qe_invalid;
11479 }
11480
11481 if(!p_igetl(&(temp_sub->delay),f))
11482 {
11483 return qe_invalid;
11484 }
11485
11486 if(!p_igetl(&(temp_sub->frame),f))
11487 {
11488 return qe_invalid;
11489 }
11490 }
11491 else
11492 {
11493
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_getc(&(temp_sub->speed),f))
11494 {
11495 return qe_invalid;
11496 }
11497
11498
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_getc(&(temp_sub->delay),f))
11499 {
11500 return qe_invalid;
11501 }
11502
11503
1/2
✓ Branch 0 taken 24646 times.
✗ Branch 1 not taken.
24646 if(!p_igetw(&(temp_sub->frame),f))
11504 {
11505 return qe_invalid;
11506 }
11507 }
11508
11509 24646 int32_t temp_size=0;
11510
11511 // bool deletets = false;
11512
4/4
✓ Branch 0 taken 10368 times.
✓ Branch 1 taken 1833 times.
✓ Branch 2 taken 12294 times.
✓ Branch 3 taken 151 times.
24646 switch(temp_sub->type)
11513 {
11514 case ssoTEXT:
11515 case ssoTEXTBOX:
11516 case ssoCURRENTITEMTEXT:
11517 case ssoCURRENTITEMCLASSTEXT:
11518 {
11519 word temptempsize;
11520
11521
1/2
✓ Branch 0 taken 1833 times.
✗ Branch 1 not taken.
1833 if(!p_igetw(&temptempsize,f))
11522 {
11523 return qe_invalid;
11524 }
11525
11526 //temptempsize = temp1 + (temp2 << 8);
11527 1833 temp_size = (int32_t)temptempsize;
11528
11529
11530 1833 uint32_t char_length = temp_size+2;
11531
1/2
✓ Branch 0 taken 1833 times.
✗ Branch 1 not taken.
1833 if (char_length > MAX_DP1_LEN)
11532 {
11533 return qe_invalid;
11534 }
11535 1833 tempdp1[char_length - 1] = '\0';
11536
11537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1833 times.
1833 if(temp_size)
11538 {
11539
1/2
✓ Branch 0 taken 1833 times.
✗ Branch 1 not taken.
1833 if(!pfread(tempdp1,temp_size+1,f))
11540 {
11541 return qe_invalid;
11542 }
11543 1833 }
11544 }
11545 1833 break;
11546
11547 case ssoLIFEMETER:
11548
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11549 temp_sub->d3 = 1;
11550
11551
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&(temp_sub->dp1),f))
11552 {
11553 return qe_invalid;
11554 }
11555
11556 151 break;
11557
11558
11559 case ssoCURRENTITEM:
11560
11561
1/2
✓ Branch 0 taken 10368 times.
✗ Branch 1 not taken.
10368 if(s_version < 6)
11562 {
11563 switch(temp_sub->d1)
11564 {
11565 case ssiBOMB:
11566 temp_sub->d1 = itype_bomb;
11567 break;
11568
11569 case ssiSWORD:
11570 temp_sub->d1 = itype_sword;
11571 break;
11572
11573 case ssiSHIELD:
11574 temp_sub->d1 = itype_shield;
11575 break;
11576
11577 case ssiCANDLE:
11578 temp_sub->d1 = itype_candle;
11579 break;
11580
11581 case ssiLETTER:
11582 temp_sub->d1 = itype_letter;
11583 break;
11584
11585 case ssiPOTION:
11586 temp_sub->d1 = itype_potion;
11587 break;
11588
11589 case ssiLETTERPOTION:
11590 temp_sub->d1 = itype_letterpotion;
11591 break;
11592
11593 case ssiBOW:
11594 temp_sub->d1 = itype_bow;
11595 break;
11596
11597 case ssiARROW:
11598 temp_sub->d1 = itype_arrow;
11599 break;
11600
11601 case ssiBOWANDARROW:
11602 temp_sub->d1 = itype_bowandarrow;
11603 break;
11604
11605 case ssiBAIT:
11606 temp_sub->d1 = itype_bait;
11607 break;
11608
11609 case ssiRING:
11610 temp_sub->d1 = itype_ring;
11611 break;
11612
11613 case ssiBRACELET:
11614 temp_sub->d1 = itype_bracelet;
11615 break;
11616
11617 case ssiMAP:
11618 temp_sub->d1 = itype_map;
11619 break;
11620
11621 case ssiCOMPASS:
11622 temp_sub->d1 = itype_compass;
11623 break;
11624
11625 case ssiBOSSKEY:
11626 temp_sub->d1 = itype_bosskey;
11627 break;
11628
11629 case ssiMAGICKEY:
11630 temp_sub->d1 = itype_magickey;
11631 break;
11632
11633 case ssiBRANG:
11634 temp_sub->d1 = itype_brang;
11635 break;
11636
11637 case ssiWAND:
11638 temp_sub->d1 = itype_wand;
11639 break;
11640
11641 case ssiRAFT:
11642 temp_sub->d1 = itype_raft;
11643 break;
11644
11645 case ssiLADDER:
11646 temp_sub->d1 = itype_ladder;
11647 break;
11648
11649 case ssiWHISTLE:
11650 temp_sub->d1 = itype_whistle;
11651 break;
11652
11653 case ssiBOOK:
11654 temp_sub->d1 = itype_book;
11655 break;
11656
11657 case ssiWALLET:
11658 temp_sub->d1 = itype_wallet;
11659 break;
11660
11661 case ssiSBOMB:
11662 temp_sub->d1 = itype_sbomb;
11663 break;
11664
11665 case ssiHCPIECE:
11666 temp_sub->d1 = itype_heartpiece;
11667 break;
11668
11669 case ssiAMULET:
11670 temp_sub->d1 = itype_amulet;
11671 break;
11672
11673 case ssiFLIPPERS:
11674 temp_sub->d1 = itype_flippers;
11675 break;
11676
11677 case ssiHOOKSHOT:
11678 temp_sub->d1 = itype_hookshot;
11679 break;
11680
11681 case ssiLENS:
11682 temp_sub->d1 = itype_lens;
11683 break;
11684
11685 case ssiHAMMER:
11686 temp_sub->d1 = itype_hammer;
11687 break;
11688
11689 case ssiBOOTS:
11690 temp_sub->d1 = itype_boots;
11691 break;
11692
11693 case ssiDIVINEFIRE:
11694 temp_sub->d1 = itype_divinefire;
11695 break;
11696
11697 case ssiDIVINEESCAPE:
11698 temp_sub->d1 = itype_divineescape;
11699 break;
11700
11701 case ssiDIVINEPROTECTION:
11702 temp_sub->d1 = itype_divineprotection;
11703 break;
11704
11705 case ssiQUIVER:
11706 temp_sub->d1 = itype_quiver;
11707 break;
11708
11709 case ssiBOMBBAG:
11710 temp_sub->d1 = itype_bombbag;
11711 break;
11712
11713 case ssiCBYRNA:
11714 temp_sub->d1 = itype_cbyrna;
11715 break;
11716
11717 case ssiROCS:
11718 temp_sub->d1 = itype_rocs;
11719 break;
11720
11721 case ssiHOVERBOOTS:
11722 temp_sub->d1 = itype_hoverboots;
11723 break;
11724
11725 case ssiSPINSCROLL:
11726 temp_sub->d1 = itype_spinscroll;
11727 break;
11728
11729 case ssiCROSSSCROLL:
11730 temp_sub->d1 = itype_crossscroll;
11731 break;
11732
11733 case ssiQUAKESCROLL:
11734 temp_sub->d1 = itype_quakescroll;
11735 break;
11736
11737 case ssiWHISPRING:
11738 temp_sub->d1 = itype_whispring;
11739 break;
11740
11741 case ssiCHARGERING:
11742 temp_sub->d1 = itype_chargering;
11743 break;
11744
11745 case ssiPERILSCROLL:
11746 temp_sub->d1 = itype_perilscroll;
11747 break;
11748
11749 case ssiWEALTHMEDAL:
11750 temp_sub->d1 = itype_wealthmedal;
11751 break;
11752
11753 case ssiHEARTRING:
11754 temp_sub->d1 = itype_heartring;
11755 break;
11756
11757 case ssiMAGICRING:
11758 temp_sub->d1 = itype_magicring;
11759 break;
11760
11761 case ssiSPINSCROLL2:
11762 temp_sub->d1 = itype_spinscroll2;
11763 break;
11764
11765 case ssiQUAKESCROLL2:
11766 temp_sub->d1 = itype_quakescroll2;
11767 break;
11768
11769 case ssiAGONY:
11770 temp_sub->d1 = itype_agony;
11771 break;
11772
11773 case ssiSTOMPBOOTS:
11774 temp_sub->d1 = itype_stompboots;
11775 break;
11776
11777 case ssiWHIMSICALRING:
11778 temp_sub->d1 = itype_whimsicalring;
11779 break;
11780
11781 case ssiPERILRING:
11782 temp_sub->d1 = itype_perilring;
11783 break;
11784
11785 default:
11786 temp_sub->d1 += itype_custom1 - ssiMAX;
11787 }
11788 }
11789
11790 //fall-through
11791 default:
11792
1/2
✓ Branch 0 taken 22662 times.
✗ Branch 1 not taken.
22662 if(!p_getc(&(temp_sub->dp1),f))
11793 {
11794 return qe_invalid;
11795 }
11796
11797 22662 break;
11798 }
11799
11800
2/2
✓ Branch 0 taken 15962 times.
✓ Branch 1 taken 8684 times.
24646 if(s_version < 7)
11801 {
11802
3/3
✓ Branch 0 taken 8025 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 432 times.
8684 switch(temp_sub->type)
11803 {
11804 case ssoMAGICGAUGE:
11805 {
11806
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 192 times.
227 if(!temp_sub->d9)
11807 192 temp_sub->d9 = -1; //-1 now represents 'always'
11808 227 break;
11809 }
11810 case ssoLIFEGAUGE:
11811 432 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11812 432 break;
11813 }
11814 8684 }
11815
11816
3/3
✓ Branch 0 taken 1833 times.
✓ Branch 1 taken 21726 times.
✓ Branch 2 taken 1087 times.
24646 switch(temp_sub->type)
11817 {
11818 case ssoTEXT:
11819 case ssoTEXTBOX:
11820 case ssoCURRENTITEMTEXT:
11821 case ssoCURRENTITEMCLASSTEXT:
11822
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1833 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1833 if(custom_subscreen[i].objects[j].dp1 != NULL) delete[](char *)custom_subscreen[i].objects[j].dp1;
11823
11824 1833 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11825 1833 custom_subscreen[i].objects[j].dp1 = NULL;
11826 1833 custom_subscreen[i].objects[j].dp1 = new char[temp_size+2];
11827 1833 strcpy((char*)custom_subscreen[i].objects[j].dp1,tempdp1);
11828 1833 break;
11829
11830 case ssoCOUNTER:
11831
1/2
✓ Branch 0 taken 1087 times.
✗ Branch 1 not taken.
1087 if(s_version<3)
11832 {
11833 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11834 temp_sub->d8=0;
11835 }
11836
11837 default:
11838 22813 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11839 22813 break;
11840 }
11841
11842 24646 custom_subscreen[i].name[0] = '\0';
11843 24646 strncat(custom_subscreen[i].name, tempname, 64 - 1);
11844 24646 custom_subscreen[i].ss_type = temp_ss;
11845 24646 }
11846
11847
2/2
✓ Branch 0 taken 3481530 times.
✓ Branch 1 taken 13696 times.
3495226 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11848 {
11849 //clear all unused object in this subscreen -DD
11850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3481530 times.
3481530 switch(custom_subscreen[i].objects[j].type)
11851 {
11852 case ssoTEXT:
11853 case ssoTEXTBOX:
11854 case ssoCURRENTITEMTEXT:
11855 case ssoCURRENTITEMCLASSTEXT:
11856 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11857
11858 //fall through
11859 default:
11860 3481530 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11861 3481530 break;
11862 }
11863 3481530 }
11864
11865 13696 return 0;
11866 13696 }
11867
11868 3968 void reset_subscreen(subscreen_group *tempss)
11869 {
11870
2/2
✓ Branch 0 taken 1015808 times.
✓ Branch 1 taken 3968 times.
1019776 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11871 {
11872
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 1015603 times.
1015808 switch(tempss->objects[i].type)
11873 {
11874 case ssoTEXT:
11875 case ssoTEXTBOX:
11876 case ssoCURRENTITEMTEXT:
11877 case ssoCURRENTITEMCLASSTEXT:
11878
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
✓ Branch 2 taken 205 times.
✗ Branch 3 not taken.
205 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11879
11880 //fall through
11881 default:
11882 1015808 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11883 1015808 break;
11884 }
11885 1015808 }
11886 3968 }
11887
11888 31 void reset_subscreens()
11889 {
11890
2/2
✓ Branch 0 taken 3968 times.
✓ Branch 1 taken 31 times.
3999 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; ++i)
11891 {
11892 3968 reset_subscreen(&custom_subscreen[i]);
11893 3968 }
11894 31 }
11895
11896 31 int32_t setupsubscreens()
11897 {
11898 31 reset_subscreens();
11899 31 int32_t tempsubscreen=zinit.subscreen;
11900 subscreen_object *tempsub;
11901
11902
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(tempsubscreen>=ssdtMAX)
11903 {
11904 tempsubscreen=0;
11905 }
11906
11907
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
31 switch(tempsubscreen)
11908 {
11909 case ssdtOLD:
11910 case ssdtNEWSUBSCR:
11911 case ssdtREV2:
11912 case ssdtBSZELDA:
11913 case ssdtBSZELDAMODIFIED:
11914 case ssdtBSZELDAENHANCED:
11915 case ssdtBSZELDACOMPLETE:
11916 {
11917 31 tempsub = default_subscreen_active[tempsubscreen][0];
11918 int32_t i;
11919
11920
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2046 times.
✓ Branch 2 taken 2015 times.
✓ Branch 3 taken 31 times.
2046 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
11921 {
11922
2/3
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 1933 times.
✗ Branch 2 not taken.
2015 switch(tempsub[i].type)
11923 {
11924 case ssoTEXT:
11925 case ssoTEXTBOX:
11926 case ssoCURRENTITEMTEXT:
11927 case ssoCURRENTITEMCLASSTEXT:
11928
1/4
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
82 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
11929
11930 82 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11931 82 custom_subscreen[0].objects[i].dp1 = NULL;
11932 82 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
11933 82 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
11934 82 break;
11935
11936 case ssoLIFEMETER:
11937 {
11938 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11939
11940 if(get_bit(deprecated_rules, 12) != 0)
11941 custom_subscreen[0].objects[i].d3=1;
11942 else
11943 custom_subscreen[0].objects[i].d3=0;
11944
11945 break;
11946 }
11947 /*
11948 case ssoTRIFRAME:
11949 {
11950 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11951 custom_subscreen[0].objects[i].d1 = 8594;
11952 custom_subscreen[0].objects[i].d2 = 8;
11953 custom_subscreen[0].objects[i].d3 = 8771;
11954 custom_subscreen[0].objects[i].d4 = 8;
11955 custom_subscreen[0].objects[i].d5 = 1;
11956 custom_subscreen[0].objects[i].d6 = 1;
11957 break;
11958 }*/
11959
11960 default:
11961 1933 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11962 1933 break;
11963 }
11964 2015 }
11965
11966 31 custom_subscreen[0].ss_type=sstACTIVE;
11967 31 sprintf(custom_subscreen[0].name, "Active Subscreen (Triforce)");
11968 31 tempsub = default_subscreen_active[tempsubscreen][1];
11969
11970
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2046 times.
✓ Branch 2 taken 2015 times.
✓ Branch 3 taken 31 times.
2046 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
11971 {
11972
2/3
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 1920 times.
✗ Branch 2 not taken.
2015 switch(tempsub[i].type)
11973 {
11974 case ssoTEXT:
11975 case ssoTEXTBOX:
11976 case ssoCURRENTITEMTEXT:
11977 case ssoCURRENTITEMCLASSTEXT:
11978
1/4
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
95 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
11979
11980 95 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
11981 95 custom_subscreen[1].objects[i].dp1 = NULL;
11982 95 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
11983 95 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
11984 95 break;
11985
11986 case ssoLIFEMETER:
11987 {
11988 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
11989
11990 if(get_bit(deprecated_rules, 12) != 0)
11991 custom_subscreen[1].objects[i].d3=1;
11992 else
11993 custom_subscreen[1].objects[i].d3=0;
11994
11995 break;
11996 }
11997 /*
11998 case ssoTRIFRAME:
11999 {
12000 custom_subscreen[1].objects[i].d1 = 8594;
12001 custom_subscreen[1].objects[i].d2 = 8;
12002 custom_subscreen[1].objects[i].d3 = 8771;
12003 custom_subscreen[1].objects[i].d4 = 8;
12004 custom_subscreen[1].objects[i].d5 = 1;
12005 custom_subscreen[1].objects[i].d6 = 1;
12006 break;
12007 }*/
12008
12009 default:
12010 1920 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12011 1920 break;
12012 }
12013 2015 }
12014
12015 31 custom_subscreen[1].ss_type=sstACTIVE;
12016 31 sprintf(custom_subscreen[1].name, "Active Subscreen (Dungeon Map)");
12017 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12018 31 tempsub = default_subscreen_passive[tempsubscreen][0];
12019
12020
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 651 times.
✓ Branch 2 taken 620 times.
✓ Branch 3 taken 31 times.
651 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12021 {
12022
3/3
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 496 times.
✓ Branch 2 taken 31 times.
620 switch(tempsub[i].type)
12023 {
12024 case ssoTEXT:
12025 case ssoTEXTBOX:
12026 case ssoCURRENTITEMTEXT:
12027 case ssoCURRENTITEMCLASSTEXT:
12028
1/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12029
12030 93 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12031 93 custom_subscreen[2].objects[i].dp1 = NULL;
12032 93 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12033 93 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12034 93 break;
12035
12036 case ssoLIFEMETER:
12037 {
12038 31 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12039
12040
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 17 times.
31 if(get_bit(deprecated_rules, 12) != 0)
12041 14 custom_subscreen[2].objects[i].d3=1;
12042 else
12043 17 custom_subscreen[2].objects[i].d3=0;
12044
12045 31 break;
12046 }
12047
12048 default:
12049 496 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12050 496 break;
12051 }
12052 620 }
12053
12054 31 custom_subscreen[2].ss_type=sstPASSIVE;
12055 31 sprintf(custom_subscreen[2].name, "Passive Subscreen (Magic)");
12056 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12057 31 tempsub = default_subscreen_passive[tempsubscreen][1];
12058
12059
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 620 times.
✓ Branch 2 taken 589 times.
✓ Branch 3 taken 31 times.
620 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12060 {
12061
3/3
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 465 times.
✓ Branch 2 taken 31 times.
589 switch(tempsub[i].type)
12062 {
12063 case ssoTEXT:
12064 case ssoTEXTBOX:
12065 case ssoCURRENTITEMTEXT:
12066 case ssoCURRENTITEMCLASSTEXT:
12067
1/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12068
12069 93 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12070 93 custom_subscreen[3].objects[i].dp1 = NULL;
12071 93 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12072 93 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12073 93 break;
12074
12075 case ssoLIFEMETER:
12076 {
12077 31 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12078
12079
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 17 times.
31 if(get_bit(deprecated_rules, 12) != 0)
12080 14 custom_subscreen[3].objects[i].d3=1;
12081 else
12082 17 custom_subscreen[3].objects[i].d3=0;
12083
12084 31 break;
12085 }
12086
12087 default:
12088 465 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12089 465 break;
12090 }
12091 589 }
12092
12093 31 custom_subscreen[3].ss_type=sstPASSIVE;
12094 31 sprintf(custom_subscreen[3].name, "Passive Subscreen (No Magic)");
12095 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12096 31 break;
12097 }
12098
12099 case ssdtZ3:
12100 {
12101 tempsub = z3_active_a;
12102 int32_t i;
12103
12104 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12105 {
12106 switch(tempsub[i].type)
12107 {
12108 case ssoTEXT:
12109 case ssoTEXTBOX:
12110 case ssoCURRENTITEMTEXT:
12111 case ssoCURRENTITEMCLASSTEXT:
12112 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12113
12114 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12115 custom_subscreen[0].objects[i].dp1 = NULL;
12116 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12117 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12118 break;
12119
12120 case ssoLIFEMETER:
12121 {
12122 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12123
12124 if(get_bit(deprecated_rules, 12) != 0)
12125 custom_subscreen[0].objects[i].d3=1;
12126 else
12127 custom_subscreen[0].objects[i].d3=0;
12128
12129 break;
12130 }
12131
12132 default:
12133 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12134 break;
12135 }
12136 }
12137
12138 custom_subscreen[0].ss_type=sstACTIVE;
12139 // memset(&custom_subscreen[0].objects[i],0,sizeof(subscreen_object));
12140 tempsub = z3_active_ab;
12141
12142 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12143 {
12144 switch(tempsub[i].type)
12145 {
12146 case ssoTEXT:
12147 case ssoTEXTBOX:
12148 case ssoCURRENTITEMTEXT:
12149 case ssoCURRENTITEMCLASSTEXT:
12150 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12151
12152 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12153 custom_subscreen[1].objects[i].dp1 = NULL;
12154 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12155 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12156 break;
12157
12158 case ssoLIFEMETER:
12159 {
12160 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12161
12162 if(get_bit(deprecated_rules, 12) != 0)
12163 custom_subscreen[1].objects[i].d3=1;
12164 else
12165 custom_subscreen[1].objects[i].d3=0;
12166
12167 break;
12168 }
12169
12170 default:
12171 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12172 break;
12173 }
12174 }
12175
12176 custom_subscreen[1].ss_type=sstACTIVE;
12177 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12178 tempsub = z3_passive_a;
12179
12180 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12181 {
12182 switch(tempsub[i].type)
12183 {
12184 case ssoTEXT:
12185 case ssoTEXTBOX:
12186 case ssoCURRENTITEMTEXT:
12187 case ssoCURRENTITEMCLASSTEXT:
12188 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12189
12190 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12191 custom_subscreen[2].objects[i].dp1 = NULL;
12192 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12193 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12194 break;
12195
12196 case ssoLIFEMETER:
12197 {
12198 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12199
12200 if(get_bit(deprecated_rules, 12) != 0)
12201 custom_subscreen[2].objects[i].d3=1;
12202 else
12203 custom_subscreen[2].objects[i].d3=0;
12204
12205 break;
12206 }
12207
12208 default:
12209 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12210 break;
12211 }
12212 }
12213
12214 custom_subscreen[2].ss_type=sstPASSIVE;
12215 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12216 tempsub = z3_passive_ab;
12217
12218 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12219 {
12220 switch(tempsub[i].type)
12221 {
12222 case ssoTEXT:
12223 case ssoTEXTBOX:
12224 case ssoCURRENTITEMTEXT:
12225 case ssoCURRENTITEMCLASSTEXT:
12226 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12227
12228 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12229 custom_subscreen[3].objects[i].dp1 = NULL;
12230 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12231 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12232 break;
12233
12234 case ssoLIFEMETER:
12235 {
12236 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12237
12238 if(get_bit(deprecated_rules, 12) != 0)
12239 custom_subscreen[3].objects[i].d3=1;
12240 else
12241 custom_subscreen[3].objects[i].d3=0;
12242
12243 break;
12244 }
12245
12246 default:
12247 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12248 break;
12249 }
12250 }
12251
12252 custom_subscreen[3].ss_type=sstPASSIVE;
12253 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12254 break;
12255 }
12256 }
12257
12258
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 124 times.
155 for(int32_t i=0; i<4; ++i)
12259 {
12260 124 purge_blank_subscreen_objects(&custom_subscreen[i]);
12261 124 }
12262
12263 31 return 0;
12264 }
12265
12266 extern script_data *ffscripts[NUMSCRIPTFFC];
12267 extern script_data *itemscripts[NUMSCRIPTITEM];
12268 extern script_data *guyscripts[NUMSCRIPTGUYS];
12269 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
12270 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12271 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12272 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12273 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12274 extern script_data *playerscripts[NUMSCRIPTPLAYER];
12275 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12276 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12277 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12278 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12279 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
12280
12281
12282
12283 103 int32_t readffscript(PACKFILE *f, zquestheader *Header)
12284 {
12285 int32_t dummy;
12286 103 word s_version=0, s_cversion=0, zmeta_version=0;
12287 103 byte numscripts=0;
12288 103 numscripts=numscripts; //to avoid unused variables warnings
12289 int32_t ret;
12290
12291 //section version info
12292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(!p_igetw(&s_version,f))
12293 {
12294 return qe_invalid;
12295 }
12296
12297 103 FFCore.quest_format[vFFScript] = s_version;
12298
12299
1/2
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
103 if(!p_igetw(&s_cversion,f))
12300 {
12301 return qe_invalid;
12302 }
12303
12304
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 30 times.
103 if(s_version >= 18)
12305 {
12306
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetw(&zmeta_version,f))
12307 {
12308 return qe_invalid;
12309 }
12310 30 }
12311
12312 //al_trace("Scripts version %d\n", s_version);
12313 //section size
12314
1/2
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
103 if(!p_igetl(&dummy,f))
12315 {
12316 return qe_invalid;
12317 }
12318
12319 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12320 103 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12321 103 temp_ffscript_version = s_version;
12322 //miscQdata *the_misc;
12323
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 77 times.
103 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12324 103 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12325
12326 //finally... section data
12327
2/2
✓ Branch 0 taken 54784 times.
✓ Branch 1 taken 97 times.
54887 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12328 {
12329 54784 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12330
12331
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if (ret)
12332 {
12333 return qe_invalid;
12334 }
12335 54784 }
12336
12337 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12338 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12339 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12340 * there was a version bump a week before a change that broke stuff.
12341 */
12342
7/8
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 30 times.
✓ Branch 5 taken 30 times.
✓ Branch 6 taken 30 times.
✓ Branch 7 taken 30 times.
97 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12343 {
12344 127 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12345 127 }
12346
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 77 times.
107 if(s_version < 19)
12347 {
12348 77 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12349 77 }
12350
12351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(s_version > 1)
12352 {
12353
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 107 times.
27499 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12354 {
12355 27392 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12356
12357
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if (ret)
12358 {
12359 return qe_invalid;
12360 }
12361 27392 }
12362
12363
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 107 times.
27499 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12364 {
12365 27392 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12366
12367
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if (ret)
12368 {
12369 return qe_invalid;
12370 }
12371 27392 }
12372
12373
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 107 times.
27499 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12374 {
12375 27392 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
12376
12377
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if (ret)
12378 {
12379 return qe_invalid;
12380 }
12381 27392 }
12382
12383
12384
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 107 times.
27499 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12385 {
12386 27392 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12387
12388
1/2
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
27392 if (ret)
12389 {
12390 return qe_invalid;
12391 }
12392 27392 }
12393
12394
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 77 times.
107 if(s_version > 16)
12395 {
12396
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 30 times.
270 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12397 {
12398 240 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12399
12400
1/2
✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
240 if (ret)
12401 {
12402 return qe_invalid;
12403 }
12404 240 }
12405 30 }
12406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 else if(s_version > 13)
12407 {
12408 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12409 {
12410 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12411
12412 if (ret)
12413 {
12414 return qe_invalid;
12415 }
12416 }
12417
12418 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12419 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12420
12421 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12422 }
12423
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 else if(s_version > 4)
12424 {
12425
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12426 {
12427 308 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12428
12429
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if (ret)
12430 {
12431 return qe_invalid;
12432 }
12433 308 }
12434
12435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12436
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12437
12438
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12439
12440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12441
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12442
12443
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12444
12445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12446
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_F6];
12447
12448
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12449
12450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12451
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12452
12453
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12454 77 }
12455 else
12456 {
12457 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12458 {
12459 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12460
12461 if (ret)
12462 {
12463 return qe_invalid;
12464 }
12465 }
12466
12467 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12468 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12469
12470 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12471
12472 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12473 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12474
12475 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12476
12477 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12478 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12479
12480 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12481
12482 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12483 delete globalscripts[GLOBAL_SCRIPT_F6];
12484
12485 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12486
12487 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12488 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12489
12490 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12491 }
12492
12493
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 77 times.
107 if(s_version > 10) //expanded the number of Player scripts to 5.
12494 {
12495
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 30 times.
180 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12496 {
12497 150 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12498
12499
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if (ret)
12500 {
12501 return qe_invalid;
12502 }
12503 150 }
12504 30 }
12505 else
12506 {
12507
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 77 times.
308 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12508 {
12509 231 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12510
12511
1/2
✓ Branch 0 taken 231 times.
✗ Branch 1 not taken.
231 if (ret)
12512 {
12513 return qe_invalid;
12514 }
12515 231 }
12516
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(playerscripts[3] != NULL)
12517
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete playerscripts[3];
12518
12519
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 playerscripts[3] = new script_data();
12520
12521
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(playerscripts[4] != NULL)
12522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 delete playerscripts[4];
12523
12524
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 playerscripts[4] = new script_data();
12525 }
12526
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
107 if(s_version > 8 && s_version < 10)
12527 {
12528
12529 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12530 {
12531 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12532
12533 if (ret)
12534 {
12535 return qe_invalid;
12536 }
12537 }
12538 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12539 {
12540 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12541
12542 if (ret)
12543 {
12544 return qe_invalid;
12545 }
12546 }
12547
12548 }
12549
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 30 times.
107 if(s_version >= 10)
12550 {
12551
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 30 times.
7710 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12552 {
12553 7680 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12554
12555
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if (ret)
12556 {
12557 return qe_invalid;
12558 }
12559 7680 }
12560
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 30 times.
7710 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12561 {
12562 7680 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12563
12564
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if (ret)
12565 {
12566 return qe_invalid;
12567 }
12568 7680 }
12569
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 30 times.
7710 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12570 {
12571 7680 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12572
12573
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if (ret)
12574 {
12575 return qe_invalid;
12576 }
12577 7680 }
12578
12579 30 }
12580
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 30 times.
107 if(s_version >=12)
12581 {
12582
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 30 times.
7710 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12583 {
12584 7680 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12585
12586
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if (ret)
12587 {
12588 return qe_invalid;
12589 }
12590 7680 }
12591 30 }
12592
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 30 times.
107 if(s_version >=15)
12593 {
12594
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 30 times.
15390 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12595 {
12596 15360 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12597
12598
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if (ret)
12599 {
12600 return qe_invalid;
12601 }
12602 15360 }
12603 30 }
12604
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 30 times.
107 if(s_version >19)
12605 {
12606 30 word numgenscripts = NUMSCRIPTSGENERIC;
12607
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetw(&numgenscripts,f))
12608 {
12609 return qe_invalid;
12610 }
12611
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 30 times.
15390 for(int32_t i = 0; i < numgenscripts; i++)
12612 {
12613 15360 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12614
12615
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if (ret)
12616 {
12617 return qe_invalid;
12618 }
12619 15360 }
12620 30 }
12621
12622 /*
12623 else //Is this trip really necessary?
12624 {
12625 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12626 {
12627
12628 ewpnscripts[i] = NULL;
12629 }
12630 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12631 {
12632 dmapscripts[i] = NULL;
12633 }
12634 }
12635 */
12636
12637 107 }
12638
12639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(s_version > 2)
12640 {
12641 int32_t bufsize;
12642 107 p_igetl(&bufsize, f);
12643
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 107 times.
107 if (bufsize < 0 || bufsize > 1024*1024*10)
12644 {
12645 // God help anyone storing more than 10MB of code in the script buffer.
12646 return qe_invalid;
12647 }
12648 107 char * buf = new char[bufsize+1];
12649 107 pfread(buf, bufsize, f);
12650 107 buf[bufsize]=0;
12651
12652
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 zScript = string(buf);
12653
12654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 delete[] buf;
12655 word numffcbindings;
12656 107 p_igetw(&numffcbindings, f);
12657
12658
2/2
✓ Branch 0 taken 1525 times.
✓ Branch 1 taken 107 times.
1632 for(int32_t i=0; i<numffcbindings; i++)
12659 {
12660 word id;
12661 1525 p_igetw(&id, f);
12662 1525 p_igetl(&bufsize, f);
12663
2/4
✓ Branch 0 taken 1525 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1525 times.
1525 if (bufsize < 0 || bufsize > 1024)
12664 return qe_invalid;
12665 1525 buf = new char[bufsize+1];
12666 1525 pfread(buf, bufsize, f);
12667 1525 buf[bufsize]=0;
12668
12669 //fix for buggy older saved quests -DD
12670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1525 times.
1525 if(id < NUMSCRIPTFFC-1)
12671 1525 ffcmap[id].scriptname = buf;
12672
12673
1/2
✓ Branch 0 taken 1525 times.
✗ Branch 1 not taken.
1525 delete[] buf;
12674 1525 }
12675
12676 word numglobalbindings;
12677 107 p_igetw(&numglobalbindings, f);
12678
12679
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 107 times.
532 for(int32_t i=0; i<numglobalbindings; i++)
12680 {
12681 word id;
12682 425 p_igetw(&id, f);
12683 425 p_igetl(&bufsize, f);
12684
2/4
✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 425 times.
✗ Branch 3 not taken.
425 if (bufsize < 0 || bufsize > 1024)
12685 return qe_invalid;
12686 425 buf = new char[bufsize+1];
12687 425 pfread(buf, bufsize, f);
12688 425 buf[bufsize]=0;
12689
12690 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12691 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12692 // Ignore these. -DD
12693
3/4
✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 266 times.
425 if(id >= 0 && id < NUMSCRIPTGLOBAL)
12694 {
12695 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12696
1/2
✓ Branch 0 taken 266 times.
✗ Branch 1 not taken.
266 if(strcmp(buf,"~Continue") == 0)
12697 {
12698 globalmap[id].scriptname = "";
12699
12700 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12701 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12702 }
12703 else
12704 {
12705 266 globalmap[id].scriptname = buf;
12706 }
12707 266 }
12708
12709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 delete[] buf;
12710 425 }
12711
12712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(s_version > 3)
12713 {
12714 word numitembindings;
12715 107 p_igetw(&numitembindings, f);
12716
12717
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 107 times.
205 for(int32_t i=0; i<numitembindings; i++)
12718 {
12719 word id;
12720 98 p_igetw(&id, f);
12721 98 p_igetl(&bufsize, f);
12722
2/4
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
98 if (bufsize < 0 || bufsize > 1024)
12723 return qe_invalid;
12724 98 buf = new char[bufsize+1];
12725 98 pfread(buf, bufsize, f);
12726 98 buf[bufsize]=0;
12727
12728 //fix this too
12729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 if(id <NUMSCRIPTITEM-1)
12730 98 itemmap[id].scriptname = buf;
12731
12732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 delete[] buf;
12733 98 }
12734 107 }
12735 //(v9+)
12736
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 30 times.
107 if(s_version > 8)
12737 {
12738 //npc scripts
12739 word numnpcbindings;
12740 30 p_igetw(&numnpcbindings, f);
12741
12742
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 30 times.
42 for(int32_t i=0; i<numnpcbindings; i++)
12743 {
12744 word id;
12745 12 p_igetw(&id, f);
12746 12 p_igetl(&bufsize, f);
12747
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if (bufsize < 0 || bufsize > 1024)
12748 return qe_invalid;
12749 12 buf = new char[bufsize+1];
12750 12 pfread(buf, bufsize, f);
12751 12 buf[bufsize]=0;
12752
12753 //fix this too
12754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(id <NUMSCRIPTGUYS-1)
12755 12 npcmap[id].scriptname = buf;
12756
12757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 delete[] buf;
12758 12 }
12759 //lweapon
12760 word numlwpnbindings;
12761 30 p_igetw(&numlwpnbindings, f);
12762
12763
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 30 times.
72 for(int32_t i=0; i<numlwpnbindings; i++)
12764 {
12765 word id;
12766 42 p_igetw(&id, f);
12767 42 p_igetl(&bufsize, f);
12768
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
42 if (bufsize < 0 || bufsize > 1024)
12769 return qe_invalid;
12770 42 buf = new char[bufsize+1];
12771 42 pfread(buf, bufsize, f);
12772 42 buf[bufsize]=0;
12773
12774 //fix this too
12775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(id <NUMSCRIPTWEAPONS-1)
12776 42 lwpnmap[id].scriptname = buf;
12777
12778
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 delete[] buf;
12779 42 }
12780 //eweapon
12781 word numewpnbindings;
12782 30 p_igetw(&numewpnbindings, f);
12783
12784
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 30 times.
93 for(int32_t i=0; i<numewpnbindings; i++)
12785 {
12786 word id;
12787 63 p_igetw(&id, f);
12788 63 p_igetl(&bufsize, f);
12789
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
63 if (bufsize < 0 || bufsize > 1024)
12790 return qe_invalid;
12791 63 buf = new char[bufsize+1];
12792 63 pfread(buf, bufsize, f);
12793 63 buf[bufsize]=0;
12794
12795 //fix this too
12796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(id <NUMSCRIPTWEAPONS-1)
12797 63 ewpnmap[id].scriptname = buf;
12798
12799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 delete[] buf;
12800 63 }
12801 //hero
12802 word numherobindings;
12803 30 p_igetw(&numherobindings, f);
12804
12805
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 30 times.
35 for(int32_t i=0; i<numherobindings; i++)
12806 {
12807 word id;
12808 5 p_igetw(&id, f);
12809 5 p_igetl(&bufsize, f);
12810
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if (bufsize < 0 || bufsize > 1024)
12811 return qe_invalid;
12812 5 buf = new char[bufsize+1];
12813 5 pfread(buf, bufsize, f);
12814 5 buf[bufsize]=0;
12815
12816 //fix this too
12817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(id <NUMSCRIPTPLAYER-1)
12818 5 playermap[id].scriptname = buf;
12819
12820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 delete[] buf;
12821 5 }
12822 //dmaps
12823 word numdmapbindings;
12824 30 p_igetw(&numdmapbindings, f);
12825
12826
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 30 times.
57 for(int32_t i=0; i<numdmapbindings; i++)
12827 {
12828 word id;
12829 27 p_igetw(&id, f);
12830 27 p_igetl(&bufsize, f);
12831
2/4
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
27 if (bufsize < 0 || bufsize > 1024)
12832 return qe_invalid;
12833 27 buf = new char[bufsize+1];
12834 27 pfread(buf, bufsize, f);
12835 27 buf[bufsize]=0;
12836
12837 //fix this too
12838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(id <NUMSCRIPTSDMAP-1)
12839 27 dmapmap[id].scriptname = buf;
12840
12841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 delete[] buf;
12842 27 }
12843 //screen
12844 word numscreenbindings;
12845 30 p_igetw(&numscreenbindings, f);
12846
12847
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 30 times.
48 for(int32_t i=0; i<numscreenbindings; i++)
12848 {
12849 word id;
12850 18 p_igetw(&id, f);
12851 18 p_igetl(&bufsize, f);
12852
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 if (bufsize < 0 || bufsize > 1024)
12853 return qe_invalid;
12854 18 buf = new char[bufsize+1];
12855 18 pfread(buf, bufsize, f);
12856 18 buf[bufsize]=0;
12857
12858 //fix this too
12859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(id <NUMSCRIPTSDMAP-1)
12860 18 screenmap[id].scriptname = buf;
12861
12862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 delete[] buf;
12863 18 }
12864 30 }
12865
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 30 times.
107 if(s_version > 11)
12866 {
12867 word numspritebindings;
12868 30 p_igetw(&numspritebindings, f);
12869
12870
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 30 times.
40 for(int32_t i=0; i<numspritebindings; i++)
12871 {
12872 word id;
12873 10 p_igetw(&id, f);
12874 10 p_igetl(&bufsize, f);
12875
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
10 if (bufsize < 0 || bufsize > 1024)
12876 return qe_invalid;
12877 10 buf = new char[bufsize+1];
12878 10 pfread(buf, bufsize, f);
12879 10 buf[bufsize]=0;
12880
12881 //fix this too
12882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(id <NUMSCRIPTSDMAP-1)
12883 10 itemspritemap[id].scriptname = buf;
12884
12885
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 delete[] buf;
12886 10 }
12887 30 }
12888
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 30 times.
107 if(s_version >= 15)
12889 {
12890 word numcombobindings;
12891 30 p_igetw(&numcombobindings, f);
12892
12893
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 30 times.
53 for(int32_t i=0; i<numcombobindings; i++)
12894 {
12895 word id;
12896 23 p_igetw(&id, f);
12897 23 p_igetl(&bufsize, f);
12898
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if (bufsize < 0 || bufsize > 1024)
12899 return qe_invalid;
12900 23 buf = new char[bufsize+1];
12901 23 pfread(buf, bufsize, f);
12902 23 buf[bufsize]=0;
12903
12904 //fix this too
12905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(id <NUMSCRIPTSCOMBODATA-1)
12906 23 comboscriptmap[id].scriptname = buf;
12907
12908
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 delete[] buf;
12909 23 }
12910 30 }
12911
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 30 times.
107 if(s_version > 19)
12912 {
12913 word numgenericbindings;
12914 30 p_igetw(&numgenericbindings, f);
12915
12916
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 30 times.
43 for(int32_t i=0; i<numgenericbindings; i++)
12917 {
12918 word id;
12919 13 p_igetw(&id, f);
12920 13 p_igetl(&bufsize, f);
12921
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if (bufsize < 0 || bufsize > 1024)
12922 return qe_invalid;
12923 13 buf = new char[bufsize+1];
12924 13 pfread(buf, bufsize, f);
12925 13 buf[bufsize]=0;
12926
12927 //fix this too
12928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(id <NUMSCRIPTSGENERIC-1)
12929 13 genericmap[id].scriptname = buf;
12930
12931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 delete[] buf;
12932 13 }
12933 30 }
12934 107 }
12935
12936 107 return 0;
12937 107 }
12938
12939 123 void reset_scripts()
12940 {
12941 #ifdef IS_PLAYER
12942 // We can't modify the script data while jit threads are possibly compiling them.
12943 void jit_shutdown();
12944 123 jit_shutdown();
12945 #endif
12946
12947 123 next_script_data_debug_id = 0;
12948
12949
2/2
✓ Branch 0 taken 62976 times.
✓ Branch 1 taken 123 times.
63099 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12950 {
12951
2/2
✓ Branch 0 taken 42496 times.
✓ Branch 1 taken 20480 times.
62976 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12952
1/2
✓ Branch 0 taken 20480 times.
✗ Branch 1 not taken.
20480 else genericscripts[i] = new script_data();
12953 62976 }
12954
12955
2/2
✓ Branch 0 taken 62976 times.
✓ Branch 1 taken 123 times.
63099 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12956 {
12957
1/2
✓ Branch 0 taken 62976 times.
✗ Branch 1 not taken.
62976 if(ffscripts[i]!=NULL)
12958 {
12959 62976 ffscripts[i]->disable();
12960 62976 }
12961 else
12962 {
12963 ffscripts[i] = new script_data();
12964 }
12965 62976 }
12966
12967
2/2
✓ Branch 0 taken 31488 times.
✓ Branch 1 taken 123 times.
31611 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12968 {
12969
1/2
✓ Branch 0 taken 31488 times.
✗ Branch 1 not taken.
31488 if(itemscripts[i]!=NULL)
12970 {
12971 31488 itemscripts[i]->disable();
12972 31488 }
12973 else
12974 {
12975 itemscripts[i] = new script_data();
12976 }
12977 31488 }
12978
12979
2/2
✓ Branch 0 taken 31488 times.
✓ Branch 1 taken 123 times.
31611 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12980 {
12981
1/2
✓ Branch 0 taken 31488 times.
✗ Branch 1 not taken.
31488 if(guyscripts[i]!=NULL)
12982 {
12983 31488 guyscripts[i]->disable();
12984 31488 }
12985 else
12986 {
12987 guyscripts[i] = new script_data();
12988 }
12989 31488 }
12990
12991
2/2
✓ Branch 0 taken 31488 times.
✓ Branch 1 taken 123 times.
31611 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12992 {
12993
1/2
✓ Branch 0 taken 31488 times.
✗ Branch 1 not taken.
31488 if(wpnscripts[i]!=NULL)
12994 {
12995 31488 wpnscripts[i]->disable();
12996 31488 }
12997 else
12998 {
12999 wpnscripts[i] = new script_data();
13000 }
13001 31488 }
13002
13003
2/2
✓ Branch 0 taken 31488 times.
✓ Branch 1 taken 123 times.
31611 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13004 {
13005
1/2
✓ Branch 0 taken 31488 times.
✗ Branch 1 not taken.
31488 if(screenscripts[i]!=NULL)
13006 {
13007 31488 screenscripts[i]->disable();
13008 31488 }
13009 else
13010 {
13011 screenscripts[i] = new script_data();
13012 }
13013 31488 }
13014
13015
2/2
✓ Branch 0 taken 984 times.
✓ Branch 1 taken 123 times.
1107 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13016 {
13017
1/2
✓ Branch 0 taken 984 times.
✗ Branch 1 not taken.
984 if(globalscripts[i]!=NULL)
13018 {
13019 984 globalscripts[i]->disable();
13020 984 }
13021 else
13022 {
13023 globalscripts[i] = new script_data();
13024 }
13025 984 }
13026
13027
2/2
✓ Branch 0 taken 615 times.
✓ Branch 1 taken 123 times.
738 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13028 {
13029
1/2
✓ Branch 0 taken 615 times.
✗ Branch 1 not taken.
615 if(playerscripts[i]!=NULL)
13030 {
13031 615 playerscripts[i]->disable();
13032 615 }
13033 else
13034 {
13035 playerscripts[i] = new script_data();
13036 }
13037 615 }
13038
13039
2/2
✓ Branch 0 taken 31488 times.
✓ Branch 1 taken 123 times.
31611 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13040 {
13041
1/2
✓ Branch 0 taken 31488 times.
✗ Branch 1 not taken.
31488 if(lwpnscripts[i]!=NULL)
13042 {
13043 31488 lwpnscripts[i]->disable();
13044 31488 }
13045 else
13046 {
13047 lwpnscripts[i] = new script_data();
13048 }
13049 31488 }
13050
13051
2/2
✓ Branch 0 taken 31488 times.
✓ Branch 1 taken 123 times.
31611 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13052 {
13053
1/2
✓ Branch 0 taken 31488 times.
✗ Branch 1 not taken.
31488 if(ewpnscripts[i]!=NULL)
13054 {
13055 31488 ewpnscripts[i]->disable();
13056 31488 }
13057 else
13058 {
13059 ewpnscripts[i] = new script_data();
13060 }
13061 31488 }
13062
13063
2/2
✓ Branch 0 taken 31488 times.
✓ Branch 1 taken 123 times.
31611 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13064 {
13065
1/2
✓ Branch 0 taken 31488 times.
✗ Branch 1 not taken.
31488 if(dmapscripts[i]!=NULL)
13066 {
13067 31488 dmapscripts[i]->disable();
13068 31488 }
13069 else
13070 {
13071 dmapscripts[i] = new script_data();
13072 }
13073 31488 }
13074
13075
2/2
✓ Branch 0 taken 31488 times.
✓ Branch 1 taken 123 times.
31611 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13076 {
13077
1/2
✓ Branch 0 taken 31488 times.
✗ Branch 1 not taken.
31488 if(itemspritescripts[i]!=NULL)
13078 {
13079 31488 itemspritescripts[i]->disable();
13080 31488 }
13081 else
13082 {
13083 itemspritescripts[i] = new script_data();
13084 }
13085 31488 }
13086
13087
2/2
✓ Branch 0 taken 62976 times.
✓ Branch 1 taken 123 times.
63099 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13088 {
13089
1/2
✓ Branch 0 taken 62976 times.
✗ Branch 1 not taken.
62976 if(comboscripts[i]!=NULL)
13090 {
13091 62976 comboscripts[i]->disable();
13092 62976 }
13093 else
13094 {
13095 comboscripts[i] = new script_data();
13096 }
13097 62976 }
13098 123 }
13099
13100 extern script_command command_list[];
13101 226721 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, word , script_data **script, word zmeta_version)
13102 {
13103 //Please also update loadquest() when modifying this method -DD
13104 226721 char b33[34] = {0};
13105 226721 b33[33] = 0;
13106 226721 ffscript temp_script;
13107 226721 int32_t num_commands=1000;
13108
13109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226721 times.
226721 if(s_version>=2)
13110 {
13111
2/4
✓ Branch 0 taken 226721 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226721 times.
✗ Branch 3 not taken.
226721 if(!p_igetl(&num_commands,f))
13112 {
13113 return qe_invalid;
13114 }
13115 226721 }
13116
13117 #ifdef ZC_FUZZ
13118 const int32_t command_limit = 300000;
13119 #else
13120 226721 const int32_t command_limit = 10000000;
13121 #endif
13122
2/4
✓ Branch 0 taken 226721 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226721 times.
✗ Branch 3 not taken.
226721 if (num_commands < 0 || num_commands > command_limit)
13123 {
13124 return qe_invalid;
13125 }
13126
13127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226721 times.
226721 if((*script) != NULL)
13128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226721 times.
226721 delete (*script);
13129
2/4
✓ Branch 0 taken 226721 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226721 times.
✗ Branch 3 not taken.
226721 (*script) = new script_data(num_commands);
13130
13131
2/2
✓ Branch 0 taken 107910 times.
✓ Branch 1 taken 118811 times.
226721 if(s_version >= 16)
13132 {
13133
1/2
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
107910 zasm_meta temp_meta;
13134
13135
2/4
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107910 times.
✗ Branch 3 not taken.
107910 if(!p_igetw(&(temp_meta.zasm_v),f))
13136 {
13137 return qe_invalid;
13138 }
13139
13140
2/4
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107910 times.
✗ Branch 3 not taken.
107910 if(!p_igetw(&(temp_meta.meta_v),f))
13141 {
13142 return qe_invalid;
13143 }
13144
13145
2/4
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107910 times.
✗ Branch 3 not taken.
107910 if(!p_igetw(&(temp_meta.ffscript_v),f))
13146 {
13147 return qe_invalid;
13148 }
13149
13150
2/4
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107910 times.
✗ Branch 3 not taken.
107910 if(!p_getc(&(temp_meta.script_type),f))
13151 {
13152 return qe_invalid;
13153 }
13154
13155
2/2
✓ Branch 0 taken 863280 times.
✓ Branch 1 taken 107910 times.
971190 for(int32_t q = 0; q < 8; ++q)
13156 {
13157
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 805728 times.
863280 if(zmeta_version < 3)
13158 {
13159
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 1899216 times.
1956768 for(int32_t c = 0; c < 33; ++c)
13160 {
13161
2/4
✓ Branch 0 taken 1899216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1899216 times.
✗ Branch 3 not taken.
1899216 if(!p_getc(&(b33[c]),f))
13162 {
13163 return qe_invalid;
13164 }
13165 1899216 }
13166
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.run_idens[q].assign(b33);
13167 57552 }
13168 else
13169 {
13170
2/4
✓ Branch 0 taken 805728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 805728 times.
✗ Branch 3 not taken.
805728 if(!p_getcstr(&temp_meta.run_idens[q],f))
13171 {
13172 return qe_invalid;
13173 }
13174 }
13175 863280 }
13176
13177
2/2
✓ Branch 0 taken 107910 times.
✓ Branch 1 taken 863280 times.
971190 for(int32_t q = 0; q < 8; ++q)
13178 {
13179
2/4
✓ Branch 0 taken 863280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 863280 times.
✗ Branch 3 not taken.
863280 if(!p_getc(&(temp_meta.run_types[q]),f))
13180 {
13181 return qe_invalid;
13182 }
13183 863280 }
13184
13185
2/4
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107910 times.
✗ Branch 3 not taken.
107910 if(!p_getc(&(temp_meta.flags),f))
13186 {
13187 return qe_invalid;
13188 }
13189
13190
2/4
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107910 times.
✗ Branch 3 not taken.
107910 if(!p_igetw(&(temp_meta.compiler_v1),f))
13191 {
13192 return qe_invalid;
13193 }
13194
13195
2/4
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107910 times.
✗ Branch 3 not taken.
107910 if(!p_igetw(&(temp_meta.compiler_v2),f))
13196 {
13197 return qe_invalid;
13198 }
13199
13200
2/4
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107910 times.
✗ Branch 3 not taken.
107910 if(!p_igetw(&(temp_meta.compiler_v3),f))
13201 {
13202 return qe_invalid;
13203 }
13204
13205
2/4
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107910 times.
✗ Branch 3 not taken.
107910 if(!p_igetw(&(temp_meta.compiler_v4),f))
13206 {
13207 return qe_invalid;
13208 }
13209
13210
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 100716 times.
107910 if(zmeta_version == 2)
13211 {
13212
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
13213 {
13214
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f))
13215 {
13216 return qe_invalid;
13217 }
13218 237402 }
13219
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.script_name.assign(b33);
13220
13221
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
13222 {
13223
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f))
13224 {
13225 return qe_invalid;
13226 }
13227 237402 }
13228
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.author.assign(b33);
13229 7194 }
13230
1/2
✓ Branch 0 taken 100716 times.
✗ Branch 1 not taken.
100716 else if(zmeta_version > 2)
13231 {
13232
2/4
✓ Branch 0 taken 100716 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100716 times.
✗ Branch 3 not taken.
100716 if(!p_getcstr(&temp_meta.script_name,f))
13233 return qe_invalid;
13234
2/4
✓ Branch 0 taken 100716 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100716 times.
✗ Branch 3 not taken.
100716 if(!p_getcstr(&temp_meta.author,f))
13235 return qe_invalid;
13236 100716 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13237
2/2
✓ Branch 0 taken 1007160 times.
✓ Branch 1 taken 100716 times.
1107876 for(auto q = 0; q < num_meta_attrib; ++q)
13238 {
13239
2/4
✓ Branch 0 taken 1007160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1007160 times.
✗ Branch 3 not taken.
1007160 if(!p_getcstr(&temp_meta.attributes[q],f))
13240 return qe_invalid;
13241
2/4
✓ Branch 0 taken 1007160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1007160 times.
✗ Branch 3 not taken.
1007160 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13242 return qe_invalid;
13243 1007160 }
13244
2/2
✓ Branch 0 taken 805728 times.
✓ Branch 1 taken 100716 times.
906444 for(auto q = 0; q < 8; ++q)
13245 {
13246
2/4
✓ Branch 0 taken 805728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 805728 times.
✗ Branch 3 not taken.
805728 if(!p_getcstr(&temp_meta.attribytes[q],f))
13247 return qe_invalid;
13248
2/4
✓ Branch 0 taken 805728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 805728 times.
✗ Branch 3 not taken.
805728 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13249 return qe_invalid;
13250 805728 }
13251
2/2
✓ Branch 0 taken 805728 times.
✓ Branch 1 taken 100716 times.
906444 for(auto q = 0; q < 8; ++q)
13252 {
13253
2/4
✓ Branch 0 taken 805728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 805728 times.
✗ Branch 3 not taken.
805728 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13254 return qe_invalid;
13255
2/4
✓ Branch 0 taken 805728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 805728 times.
✗ Branch 3 not taken.
805728 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13256 return qe_invalid;
13257 805728 }
13258
2/2
✓ Branch 0 taken 1611456 times.
✓ Branch 1 taken 100716 times.
1712172 for(auto q = 0; q < 16; ++q)
13259 {
13260
2/4
✓ Branch 0 taken 1611456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1611456 times.
✗ Branch 3 not taken.
1611456 if(!p_getcstr(&temp_meta.usrflags[q],f))
13261 return qe_invalid;
13262
2/4
✓ Branch 0 taken 1611456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1611456 times.
✗ Branch 3 not taken.
1611456 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13263 return qe_invalid;
13264 1611456 }
13265 100716 }
13266
2/2
✓ Branch 0 taken 100716 times.
✓ Branch 1 taken 7194 times.
107910 if(zmeta_version > 3)
13267 {
13268
2/2
✓ Branch 0 taken 805728 times.
✓ Branch 1 taken 100716 times.
906444 for(auto q = 0; q < 8; ++q)
13269 {
13270
2/4
✓ Branch 0 taken 805728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 805728 times.
✗ Branch 3 not taken.
805728 if(!p_getcstr(&temp_meta.initd[q],f))
13271 return qe_invalid;
13272
2/4
✓ Branch 0 taken 805728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 805728 times.
✗ Branch 3 not taken.
805728 if(!p_getwstr(&temp_meta.initd_help[q],f))
13273 return qe_invalid;
13274 805728 }
13275
2/2
✓ Branch 0 taken 805728 times.
✓ Branch 1 taken 100716 times.
906444 for(auto q = 0; q < 8; ++q)
13276 {
13277
2/4
✓ Branch 0 taken 805728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 805728 times.
✗ Branch 3 not taken.
805728 if(!p_getc(&temp_meta.initd_type[q],f))
13278 return qe_invalid;
13279 805728 }
13280 100716 }
13281 else
13282 {
13283
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13284 {
13285
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.initd[q] = temp_meta.run_idens[q];
13286 57552 }
13287 }
13288
13289
1/2
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
107910 (*script)->meta = temp_meta;
13290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107910 times.
107910 }
13291
13292
1/2
✓ Branch 0 taken 226721 times.
✗ Branch 1 not taken.
226721 temp_script.clear();
13293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21690312 times.
21690312 for(int32_t j=0; j<num_commands; j++)
13294 {
13295
2/4
✓ Branch 0 taken 21690312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21690312 times.
✗ Branch 3 not taken.
21690312 if(!p_igetw(&(temp_script.command),f))
13296 {
13297 return qe_invalid;
13298 }
13299
13300
2/2
✓ Branch 0 taken 226721 times.
✓ Branch 1 taken 21463591 times.
21690312 if(temp_script.command == 0xFFFF)
13301 {
13302
1/2
✓ Branch 0 taken 226721 times.
✗ Branch 1 not taken.
226721 (*script)->zasm[j].clear();
13303 226721 break;
13304 }
13305 else
13306 {
13307
2/4
✓ Branch 0 taken 21463591 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21463591 times.
✗ Branch 3 not taken.
21463591 if(!p_igetl(&(temp_script.arg1),f))
13308 {
13309 return qe_invalid;
13310 }
13311
13312
2/4
✓ Branch 0 taken 21463591 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21463591 times.
✗ Branch 3 not taken.
21463591 if(!p_igetl(&(temp_script.arg2),f))
13313 {
13314 return qe_invalid;
13315 }
13316
13317
2/2
✓ Branch 0 taken 790970 times.
✓ Branch 1 taken 20672621 times.
21463591 if(s_version >= 21)
13318 {
13319 790970 uint32_t sz = 0;
13320
2/4
✓ Branch 0 taken 790970 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 790970 times.
✗ Branch 3 not taken.
790970 if(!p_igetl(&sz,f))
13321 {
13322 return qe_invalid;
13323 }
13324
2/2
✓ Branch 0 taken 2935 times.
✓ Branch 1 taken 788035 times.
790970 if(sz) //string found
13325 {
13326
1/2
✓ Branch 0 taken 2935 times.
✗ Branch 1 not taken.
2935 temp_script.strptr = new std::string();
13327 char dummy;
13328
2/2
✓ Branch 0 taken 227913 times.
✓ Branch 1 taken 2935 times.
230848 for(size_t q = 0; q < sz; ++q)
13329 {
13330
2/4
✓ Branch 0 taken 227913 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 227913 times.
✗ Branch 3 not taken.
227913 if(!p_getc(&dummy,f))
13331 {
13332 return qe_invalid;
13333 }
13334
1/2
✓ Branch 0 taken 227913 times.
✗ Branch 1 not taken.
227913 temp_script.strptr->push_back(dummy);
13335 227913 }
13336 2935 }
13337
2/4
✓ Branch 0 taken 790970 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 790970 times.
✗ Branch 3 not taken.
790970 if(!p_igetl(&sz,f))
13338 {
13339 return qe_invalid;
13340 }
13341
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 790869 times.
790970 if(sz) //vector found
13342 {
13343
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 temp_script.vecptr = new std::vector<int32_t>();
13344 int32_t dummy;
13345
2/2
✓ Branch 0 taken 1487 times.
✓ Branch 1 taken 101 times.
1588 for(size_t q = 0; q < sz; ++q)
13346 {
13347
2/4
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1487 times.
✗ Branch 3 not taken.
1487 if(!p_igetl(&dummy,f))
13348 {
13349 return qe_invalid;
13350 }
13351
1/2
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
1487 temp_script.vecptr->push_back(dummy);
13352 1487 }
13353 101 }
13354 790970 }
13355
13356
1/2
✓ Branch 0 taken 21463591 times.
✗ Branch 1 not taken.
21463591 temp_script.give((*script)->zasm[j]);
13357 }
13358
1/2
✓ Branch 0 taken 21463591 times.
✗ Branch 1 not taken.
21463591 temp_script.clear();
13359 21463591 }
13360
13361 226721 return 0;
13362 226721 }
13363
13364 extern SAMPLE customsfxdata[WAV_COUNT];
13365 extern uint8_t customsfxflag[WAV_COUNT>>3];
13366 extern int32_t sfxdat;
13367 extern DATAFILE *sfxdata;
13368 const char *old_sfx_string[Z35] =
13369 {
13370 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13371 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13372 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13373 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13374 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13375 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13376 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13377 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13378 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13379 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13380 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13381 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13382 };
13383 char *sfx_string[WAV_COUNT];
13384
13385 107 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13386 {
13387 //these are here to bypass compiler warnings about unused arguments
13388 107 Header=Header;
13389
13390 int32_t dummy;
13391 107 word s_version=0, s_cversion=0;
13392 //int32_t ret;
13393 SAMPLE temp_sample;
13394 107 temp_sample.loop_start=0;
13395 107 temp_sample.loop_end=0;
13396 107 temp_sample.param=0;
13397
13398 //section version info
13399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(!p_igetw(&s_version,f))
13400 {
13401 return qe_invalid;
13402 }
13403
13404 107 FFCore.quest_format[vSFX] = s_version;
13405
13406 //al_trace("SFX version %d\n", s_version);
13407
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetw(&s_cversion,f))
13408 {
13409 return qe_invalid;
13410 }
13411
13412 //section size
13413
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetl(&dummy,f))
13414 {
13415 return qe_invalid;
13416 }
13417
13418 /* HIGHLY UNORTHODOX UPDATING THING, by L
13419 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13420 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13421 * changing from 1 to 2.
13422 */
13423
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(s_version < 2)
13424 set_qr(qr_GOTOLESSNOTEQUAL,1);
13425
13426 /* End highly unorthodox updating thing */
13427
13428 107 int32_t wavcount = WAV_COUNT;
13429
13430
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(s_version < 6)
13431 wavcount = 128;
13432
13433 uint8_t tempflag[WAV_COUNT>>3];
13434
13435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(s_version < 4)
13436 {
13437 memset(tempflag, 0xFF, WAV_COUNT>>3);
13438 }
13439 else
13440 {
13441
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(s_version < 6)
13442 memset(tempflag, 0, WAV_COUNT>>3);
13443
13444
2/2
✓ Branch 0 taken 3424 times.
✓ Branch 1 taken 107 times.
3531 for(int32_t i=0; i<(wavcount>>3); i++)
13445 {
13446 3424 p_getc(&tempflag[i], f);
13447 3424 }
13448
13449 }
13450
13451
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(s_version>4)
13452 {
13453
2/2
✓ Branch 0 taken 27285 times.
✓ Branch 1 taken 107 times.
27392 for(int32_t i=1; i<WAV_COUNT; i++)
13454 {
13455 27285 sprintf(sfx_string[i],"s%03d",i);
13456
13457
2/2
✓ Branch 0 taken 20865 times.
✓ Branch 1 taken 6420 times.
27285 if((i<Z35))
13458 6420 strcpy(sfx_string[i], old_sfx_string[i-1]);
13459
13460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27285 times.
27285 if(i>=wavcount)
13461 continue;
13462
2/2
✓ Branch 0 taken 2582 times.
✓ Branch 1 taken 24703 times.
27285 if(get_bit(tempflag, i-1))
13463 {
13464 char tempname[36];
13465
13466
1/2
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
2582 if(!pfread(tempname, 36, f))
13467 {
13468 return qe_invalid;
13469 }
13470
13471 2582 sfx_string[i][0] = '\0';
13472 2582 strncat(sfx_string[i], tempname, 36 - 1);
13473 2582 }
13474 else
13475 {
13476 24703 sprintf(sfx_string[i],"s%03d",i);
13477
13478
2/2
✓ Branch 0 taken 20125 times.
✓ Branch 1 taken 4578 times.
24703 if(i<Z35)
13479 4578 strcpy(sfx_string[i], old_sfx_string[i-1]);
13480 24703 sfx_string[i][35] = 0; //Force NULL Termination
13481 }
13482 27285 }
13483 107 }
13484 else
13485 {
13486 for(int32_t i=1; i<WAV_COUNT; i++)
13487 {
13488 sprintf(sfx_string[i],"s%03d",i);
13489
13490 if(i<Z35)
13491 strcpy(sfx_string[i], old_sfx_string[i-1]);
13492 }
13493 }
13494
13495 //finally... section data
13496
2/2
✓ Branch 0 taken 27285 times.
✓ Branch 1 taken 107 times.
27392 for(int32_t i=1; i<wavcount; i++)
13497 {
13498
2/2
✓ Branch 0 taken 2582 times.
✓ Branch 1 taken 24703 times.
27285 if(get_bit(tempflag, i-1))
13499 {
13500
13501
1/2
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
2582 if(!p_igetl(&dummy,f))
13502 {
13503 return qe_invalid;
13504 }
13505
13506 2582 (temp_sample.bits) = dummy;
13507
13508
1/2
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
2582 if(!p_igetl(&dummy,f))
13509 {
13510 return qe_invalid;
13511 }
13512
13513 2582 (temp_sample.stereo) = dummy;
13514
13515
1/2
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
2582 if(!p_igetl(&dummy,f))
13516 {
13517 return qe_invalid;
13518 }
13519
13520 2582 (temp_sample.freq) = dummy;
13521
13522
1/2
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
2582 if(!p_igetl(&dummy,f))
13523 {
13524 return qe_invalid;
13525 }
13526
13527 2582 (temp_sample.priority) = dummy;
13528
13529
1/2
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
2582 if(!p_igetl(&(temp_sample.len),f))
13530 {
13531 return qe_invalid;
13532 }
13533
13534
1/2
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
2582 if(!p_igetl(&(temp_sample.loop_start),f))
13535 {
13536 return qe_invalid;
13537 }
13538
13539
1/2
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
2582 if(!p_igetl(&(temp_sample.loop_end),f))
13540 {
13541 return qe_invalid;
13542 }
13543
13544
1/2
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
2582 if(!p_igetl(&(temp_sample.param),f))
13545 {
13546 return qe_invalid;
13547 }
13548
13549 // al_trace("F%i: L%i\n",i,temp_sample.len);
13550 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13551 2582 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13552
2/4
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2582 times.
2582 if (len < 0 || len > 10000000)
13553 {
13554 return qe_invalid;
13555 }
13556 2582 temp_sample.data = calloc(len,1);
13557
13558
1/2
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
2582 if(s_version < 3)
13559 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13560
13561 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2582 times.
2582 if(s_version < 2)
13563 {
13564 if(!pfread(temp_sample.data, len,f))
13565 {
13566 return qe_invalid;
13567 }
13568 }
13569 else
13570 {
13571 //re-endianfy the data
13572 2582 int32_t wordstoread = len / sizeof(word);
13573
13574
2/2
✓ Branch 0 taken 77959645 times.
✓ Branch 1 taken 2582 times.
77962227 for(int32_t j=0; j<wordstoread; j++)
13575 {
13576 word temp;
13577
13578
1/2
✓ Branch 0 taken 77959645 times.
✗ Branch 1 not taken.
77959645 if(!p_igetw(&temp, f))
13579 {
13580 return qe_invalid;
13581 }
13582
13583 77959645 ((word *)temp_sample.data)[j] = temp;
13584 77959645 }
13585 }
13586 2582 }
13587
2/2
✓ Branch 0 taken 4578 times.
✓ Branch 1 taken 20125 times.
24703 else if(i < Z35)
13588 {
13589 4578 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13590 4578 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13591 4578 set_bit(tempflag, i-1, 1);
13592 4578 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13593 4578 temp_sample.data = calloc(len,1);
13594 4578 memcpy(temp_sample.data, datsamp->data, len);
13595 4578 }
13596 20125 else continue;
13597
13598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7160 times.
7160 if(customsfxdata[i].data!=NULL)
13599 {
13600 // delete [] customsfxdata[i].data;
13601 7160 free(customsfxdata[i].data);
13602 7160 }
13603
13604 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13605 7160 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13606 7160 customsfxdata[i].data = calloc(len2,1);
13607 7160 customsfxdata[i].bits = temp_sample.bits;
13608 7160 customsfxdata[i].stereo = temp_sample.stereo;
13609 7160 customsfxdata[i].freq = temp_sample.freq;
13610 7160 customsfxdata[i].priority = temp_sample.priority;
13611 7160 customsfxdata[i].len = temp_sample.len;
13612 7160 customsfxdata[i].loop_start = temp_sample.loop_start;
13613 7160 customsfxdata[i].loop_end = temp_sample.loop_end;
13614 7160 customsfxdata[i].param = temp_sample.param;
13615 7160 int32_t cpylen = len2;
13616
13617
1/2
✓ Branch 0 taken 7160 times.
✗ Branch 1 not taken.
7160 if(s_version<3)
13618 {
13619 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13620 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13621 }
13622
13623 7160 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13624
13625 7160 free(temp_sample.data);
13626 7160 }
13627
13628 107 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13629
13630 107 sfxdat=0;
13631 107 return 0;
13632 107 }
13633
13634 123 void setupsfx()
13635 {
13636
2/2
✓ Branch 0 taken 31365 times.
✓ Branch 1 taken 123 times.
31488 for(int32_t i=1; i<WAV_COUNT; i++)
13637 {
13638 31365 sprintf(sfx_string[i],"s%03d",i);
13639
13640
2/2
✓ Branch 0 taken 23985 times.
✓ Branch 1 taken 7380 times.
31365 if(i<Z35)
13641 {
13642 7380 strcpy(sfx_string[i], old_sfx_string[i-1]);
13643 7380 }
13644
13645 31365 memset(customsfxflag, 0, WAV_COUNT>>3);
13646
13647 31365 int32_t j=i;
13648
13649
2/2
✓ Branch 0 taken 7503 times.
✓ Branch 1 taken 23862 times.
31365 if(i>Z35)
13650 {
13651 23862 i=Z35;
13652 23862 }
13653
13654 31365 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13655
13656
2/2
✓ Branch 0 taken 10200 times.
✓ Branch 1 taken 21165 times.
31365 if(customsfxdata[j].data!=NULL)
13657 {
13658 // delete [] customsfxdata[j].data;
13659 21165 free(customsfxdata[j].data);
13660 21165 }
13661
13662 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13663 31365 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13664 31365 customsfxdata[j].bits = temp_sample->bits;
13665 31365 customsfxdata[j].stereo = temp_sample->stereo;
13666 31365 customsfxdata[j].freq = temp_sample->freq;
13667 31365 customsfxdata[j].priority = temp_sample->priority;
13668 31365 customsfxdata[j].len = temp_sample->len;
13669 31365 customsfxdata[j].loop_start = temp_sample->loop_start;
13670 31365 customsfxdata[j].loop_end = temp_sample->loop_end;
13671 31365 customsfxdata[j].param = temp_sample->param;
13672 31365 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13673 31365 i=j;
13674 31365 }
13675 123 }
13676
13677 extern char *guy_string[eMAXGUYS];
13678 extern const char *old_guy_string[OLDMAXGUYS];
13679
13680 123 int32_t readguys(PACKFILE *f, zquestheader *Header)
13681 {
13682 dword dummy;
13683 word guy_cversion;
13684 123 word guyversion=0;
13685
13686
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 119 times.
123 if(Header->zelda_version >= 0x193)
13687 {
13688 //section version info
13689
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&guyversion,f))
13690 {
13691 return qe_invalid;
13692 }
13693
13694 119 FFCore.quest_format[vGuys] = guyversion;
13695
13696 //al_trace("Guys version %d\n", guyversion);
13697
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&guy_cversion,f))
13698 {
13699 return qe_invalid;
13700 }
13701 119 al_trace("Guy CVersion is: %d\n", guy_cversion);
13702 //section size
13703
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetl(&dummy,f))
13704 {
13705 return qe_invalid;
13706 }
13707 119 }
13708
13709
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if(guyversion > 3)
13710 {
13711
2/2
✓ Branch 0 taken 54784 times.
✓ Branch 1 taken 107 times.
54891 for(int32_t i=0; i<MAXGUYS; i++)
13712 {
13713 char tempname[64];
13714
13715 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13716 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13717
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54784 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54784 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13718 {
13719 memset(tempname, 0, sizeof(char)*64);
13720 sprintf(tempname, "e%03d", i);
13721 strcpy(guy_string[i], tempname);
13722
13723 continue;
13724 }
13725
13726
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!pfread(tempname, 64, f))
13727 {
13728 return qe_invalid;
13729 }
13730
13731 // Don't retain names of uneditable enemy entries!
13732 // for version upgrade to 2.5
13733
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54784 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54784 if(guyversion < 23 && i >= 177)
13734 {
13735 // some of the older builds have names such as 'zz123',
13736 // (this order gets messed up with some eXXX and some zzXXX)
13737 // so let's update to the newer naming convection. -Gleeok
13738 char tmpbuf[64];
13739 memset(tmpbuf, 0, sizeof(char)*64);
13740 sprintf(tmpbuf, "zz%03d", i);
13741
13742 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13743 {
13744 memset(tempname, 0, sizeof(char)*64);
13745 sprintf(tempname, "e%03d", i);
13746 }
13747 }
13748
13749
6/6
✓ Branch 0 taken 18939 times.
✓ Branch 1 taken 35845 times.
✓ Branch 2 taken 17976 times.
✓ Branch 3 taken 963 times.
✓ Branch 4 taken 14977 times.
✓ Branch 5 taken 2999 times.
54784 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13750 {
13751 51785 guy_string[i][0] = '\0';
13752 51785 strncat(guy_string[i], tempname, 64 - 1);
13753 51785 }
13754 else
13755 {
13756 2999 strcpy(guy_string[i],old_guy_string[i]);
13757 }
13758 54784 }
13759 107 }
13760 else
13761 {
13762
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 16 times.
8208 for(int32_t i=0; i<eMAXGUYS; i++)
13763 {
13764 8192 sprintf(guy_string[i],"zz%03d",i);
13765 8192 }
13766
13767
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 16 times.
2848 for(int32_t i=0; i<OLDMAXGUYS; i++)
13768 {
13769 2832 strcpy(guy_string[i],old_guy_string[i]);
13770 2832 }
13771 }
13772
13773
13774 //finally... section data
13775 123 init_guys(guyversion); //using default data for now...
13776
13777 // Goriya guy fix
13778
3/6
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 107 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
123 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13779 {
13780
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(get_qr(qr_NEWENEMYTILES))
13781 {
13782 12 guysbuf[gGORIYA].tile=130;
13783 12 guysbuf[gGORIYA].e_tile=130;
13784 12 }
13785 16 }
13786
13787
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
123 if(Header->zelda_version < 0x193)
13788 {
13789
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(deprecated_rules,46))
13790 {
13791 guysbuf[eDODONGO].cset=14;
13792 guysbuf[eDODONGO].bosspal=spDIG;
13793 }
13794 4 }
13795 // Not sure when this first changed, but it's necessary for 2.10, at least
13796 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13797 //2.10 Fixes
13798
3/6
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 107 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
123 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13799 {
13800 16 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13801 16 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13802 16 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13803 16 guysbuf[eCENT1].misc3 = 1;
13804 16 guysbuf[eCENT2].misc3 = 1;
13805 16 }
13806
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
123 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13807 {
13808 123 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13809 123 }
13810
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if(Header->zelda_version <= 0x210)
13811 {
13812 16 guysbuf[eGLEEOK1F].misc6 = 16;
13813 16 guysbuf[eGLEEOK2F].misc6 = 16;
13814 16 guysbuf[eGLEEOK3F].misc6 = 16;
13815 16 guysbuf[eGLEEOK4F].misc6 = 16;
13816
13817 16 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13818 16 guysbuf[eBATROBE].misc4 = 1;
13819 //guysbuf[eSUMMONER].misc4 = 1;
13820 16 guysbuf[eWWIZ].misc4 = 1;
13821 16 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13822 16 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13823 16 }
13824
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
123 if(Header->zelda_version == 0x190)
13825 {
13826 4 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13827 4 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13828 4 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13829 4 }
13830
13831 // The versions here may not be correct
13832 // zelda_version>=0x211 handled at guyversion<24
13833
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 119 times.
123 if(Header->zelda_version <= 0x190)
13834 {
13835 4 guysbuf[eCENT1].misc3 = 0;
13836 4 guysbuf[eCENT2].misc3 = 0;
13837 4 guysbuf[eMOLDORM].misc2 = 0;
13838 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13839 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13840 4 }
13841
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 12 times.
119 else if(Header->zelda_version <= 0x210)
13842 {
13843 12 guysbuf[eCENT1].misc3 = 1;
13844 12 guysbuf[eCENT2].misc3 = 1;
13845 12 guysbuf[eMOLDORM].misc2 = 0;
13846 12 }
13847
13848
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13849 {
13850 16 guysbuf[eKEESE1].misc16 = 120;
13851 16 guysbuf[eKEESE2].misc16 = 120;
13852 16 guysbuf[eKEESE3].misc16 = 120;
13853 16 guysbuf[eKEESETRIB].misc16 = 120;
13854 16 guysbuf[eKEESE1].misc17 = 16;
13855 16 guysbuf[eKEESE2].misc17 = 16;
13856 16 guysbuf[eKEESE3].misc17 = 16;
13857 16 guysbuf[eKEESETRIB].misc17 = 16;
13858
13859 16 guysbuf[ePEAHAT].misc16 = 80;
13860 16 guysbuf[ePEAHAT].misc17 = 16;
13861
13862 16 guysbuf[eGHINI2].misc16 = 120;
13863 16 guysbuf[eGHINI2].misc17 = 10;
13864
13865 16 }
13866
13867
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 107 times.
123 if(guyversion<=2)
13868 {
13869 16 return readherosprites2(f, guyversion==2?0:-1, 0);
13870 }
13871
13872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(guyversion > 3)
13873 {
13874 guydata tempguy;
13875
13876
2/2
✓ Branch 0 taken 54784 times.
✓ Branch 1 taken 107 times.
54891 for(int32_t i=0; i<MAXGUYS; i++)
13877 {
13878
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(guyversion < 23) // May 2012 : 512 max enemies
13879 {
13880 if(i >= OLDBETAMAXGUYS)
13881 {
13882 memset(&guysbuf[i], 0, sizeof(guydata));
13883 continue;
13884 }
13885 }
13886
13887 54784 memset(&tempguy, 0, sizeof(guydata));
13888
13889
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetl(&(tempguy.flags),f))
13890 {
13891 return qe_invalid;
13892 }
13893
13894
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetl(&(tempguy.flags2),f))
13895 {
13896 return qe_invalid;
13897 }
13898
13899
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 39424 times.
54784 if ( guyversion >= 36 ) //expanded tiles
13900 {
13901
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.tile),f))
13902 {
13903 return qe_invalid;
13904 }
13905 15360 }
13906 else
13907 {
13908
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.tile),f))
13909 {
13910 return qe_invalid;
13911 }
13912 }
13913
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_getc(&(tempguy.width),f))
13914 {
13915 return qe_invalid;
13916 }
13917
13918
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_getc(&(tempguy.height),f))
13919 {
13920 return qe_invalid;
13921 }
13922
13923
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 39424 times.
54784 if ( guyversion >= 36 ) //expanded tiles
13924 {
13925
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.s_tile),f))
13926 {
13927 return qe_invalid;
13928 }
13929 15360 }
13930 else
13931 {
13932
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.s_tile),f))
13933 {
13934 return qe_invalid;
13935 }
13936 }
13937
13938
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_getc(&(tempguy.s_width),f))
13939 {
13940 return qe_invalid;
13941 }
13942
13943
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_getc(&(tempguy.s_height),f))
13944 {
13945 return qe_invalid;
13946 }
13947
13948
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 39424 times.
54784 if ( guyversion >= 36 ) //expanded tiles
13949 {
13950
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.e_tile),f))
13951 {
13952 return qe_invalid;
13953 }
13954 15360 }
13955 else
13956 {
13957
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.e_tile),f))
13958 {
13959 return qe_invalid;
13960 }
13961 }
13962
13963
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_getc(&(tempguy.e_width),f))
13964 {
13965 return qe_invalid;
13966 }
13967
13968
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_getc(&(tempguy.e_height),f))
13969 {
13970 return qe_invalid;
13971 }
13972
13973
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&(tempguy.hp),f))
13974 {
13975 return qe_invalid;
13976 }
13977
13978
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&(tempguy.family),f))
13979 {
13980 return qe_invalid;
13981 }
13982
13983
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 54784 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
54784 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13984 {
13985 if(get_qr(qr_NEWENEMYTILES))
13986 {
13987 tempguy.s_tile=tempguy.e_tile+120;
13988 tempguy.s_width=tempguy.e_width;
13989 tempguy.s_height=tempguy.e_height;
13990 }
13991 else tempguy.s_tile=860;
13992 }
13993
13994
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&(tempguy.cset),f))
13995 {
13996 return qe_invalid;
13997 }
13998
13999
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&(tempguy.anim),f))
14000 {
14001 return qe_invalid;
14002 }
14003
14004
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&(tempguy.e_anim),f))
14005 {
14006 return qe_invalid;
14007 }
14008
14009
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&(tempguy.frate),f))
14010 {
14011 return qe_invalid;
14012 }
14013
14014
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&(tempguy.e_frate),f))
14015 {
14016 return qe_invalid;
14017 }
14018
14019
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(guyversion < 13) // April 2009
14020 {
14021 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
14022 {
14023 tempguy.frate *= 2;
14024 tempguy.e_frate *= 2;
14025 }
14026 }
14027
14028
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(guyversion < 14) // May 1 2009
14029 {
14030 if(tempguy.anim==a2FRMSLOW)
14031 {
14032 tempguy.anim=a2FRM;
14033 tempguy.frate *= 2;
14034 }
14035
14036 if(tempguy.e_anim==a2FRMSLOW)
14037 {
14038 tempguy.e_anim=a2FRM;
14039 tempguy.e_frate *= 2;
14040 }
14041
14042 if(tempguy.anim==aFLIPSLOW)
14043 {
14044 tempguy.anim=aFLIP;
14045 tempguy.frate *= 2;
14046 }
14047
14048 if(tempguy.e_anim==aFLIPSLOW)
14049 {
14050 tempguy.e_anim=aFLIP;
14051 tempguy.e_frate *= 2;
14052 }
14053
14054 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14055
14056 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14057
14058 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14059 {
14060 tempguy.anim=a4FRM4DIR;
14061 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14062 }
14063
14064 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14065 {
14066 tempguy.e_anim=a4FRM4DIR;
14067 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14068 }
14069 }
14070
14071
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&(tempguy.dp),f))
14072 {
14073 return qe_invalid;
14074 }
14075
14076 //correction for guy fire
14077
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(guyversion < 6)
14078 {
14079 if(i == gFIRE)
14080 tempguy.dp = 2;
14081 }
14082
14083
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&(tempguy.wdp),f))
14084 {
14085 return qe_invalid;
14086 }
14087
14088
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&(tempguy.weapon),f))
14089 {
14090 return qe_invalid;
14091 }
14092
14093 //correction for bosses using triple, "rising" fireballs
14094
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(guyversion < 5)
14095 {
14096 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14097 i == eGOHMA3 || i == eGOHMA4)
14098 {
14099 if(tempguy.weapon == ewFireball)
14100 tempguy.weapon = ewFireball2;
14101 }
14102 }
14103
14104
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&(tempguy.rate),f))
14105 {
14106 return qe_invalid;
14107 }
14108
14109
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&(tempguy.hrate),f))
14110 {
14111 return qe_invalid;
14112 }
14113
14114
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&(tempguy.step),f))
14115 {
14116 return qe_invalid;
14117 }
14118
14119 // HIGHLY UNORTHODOX UPDATING THING, part 2
14120
3/4
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 53248 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
54784 if(fixpolsvoice && tempguy.family==eePOLSV)
14121 {
14122 tempguy.step /= 2;
14123 }
14124
14125
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&(tempguy.homing),f))
14126 {
14127 return qe_invalid;
14128 }
14129
14130
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&(tempguy.grumble),f))
14131 {
14132 return qe_invalid;
14133 }
14134
14135
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&(tempguy.item_set),f))
14136 {
14137 return qe_invalid;
14138 }
14139
14140
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14141 {
14142
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetl(&(tempguy.misc1),f))
14143 {
14144 return qe_invalid;
14145 }
14146
14147
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetl(&(tempguy.misc2),f))
14148 {
14149 return qe_invalid;
14150 }
14151
14152
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetl(&(tempguy.misc3),f))
14153 {
14154 return qe_invalid;
14155 }
14156
14157
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetl(&(tempguy.misc4),f))
14158 {
14159 return qe_invalid;
14160 }
14161
14162
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetl(&(tempguy.misc5),f))
14163 {
14164 return qe_invalid;
14165 }
14166
14167
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetl(&(tempguy.misc6),f))
14168 {
14169 return qe_invalid;
14170 }
14171
14172
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetl(&(tempguy.misc7),f))
14173 {
14174 return qe_invalid;
14175 }
14176
14177
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetl(&(tempguy.misc8),f))
14178 {
14179 return qe_invalid;
14180 }
14181
14182
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetl(&(tempguy.misc9),f))
14183 {
14184 return qe_invalid;
14185 }
14186
14187
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetl(&(tempguy.misc10),f))
14188 {
14189 return qe_invalid;
14190 }
14191 54784 }
14192 else
14193 {
14194 int16_t tempMisc;
14195
14196 if(!p_igetw(&tempMisc,f))
14197 {
14198 return qe_invalid;
14199 }
14200
14201 tempguy.misc1=tempMisc;
14202
14203 if(!p_igetw(&tempMisc,f))
14204 {
14205 return qe_invalid;
14206 }
14207
14208 tempguy.misc2=tempMisc;
14209
14210 if(!p_igetw(&tempMisc,f))
14211 {
14212 return qe_invalid;
14213 }
14214
14215 tempguy.misc3=tempMisc;
14216
14217 if(!p_igetw(&tempMisc,f))
14218 {
14219 return qe_invalid;
14220 }
14221
14222 tempguy.misc4=tempMisc;
14223
14224 if(!p_igetw(&tempMisc,f))
14225 {
14226 return qe_invalid;
14227 }
14228
14229 tempguy.misc5=tempMisc;
14230
14231 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14232 {
14233 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
14234 tempguy.misc5 = 74;
14235 }
14236
14237 if(!p_igetw(&tempMisc,f))
14238 {
14239 return qe_invalid;
14240 }
14241
14242 tempguy.misc6=tempMisc;
14243
14244 if(!p_igetw(&tempMisc,f))
14245 {
14246 return qe_invalid;
14247 }
14248
14249 tempguy.misc7=tempMisc;
14250
14251 if(!p_igetw(&tempMisc,f))
14252 {
14253 return qe_invalid;
14254 }
14255
14256 tempguy.misc8=tempMisc;
14257
14258 if(!p_igetw(&tempMisc,f))
14259 {
14260 return qe_invalid;
14261 }
14262
14263 tempguy.misc9=tempMisc;
14264
14265 if(!p_igetw(&tempMisc,f))
14266 {
14267 return qe_invalid;
14268 }
14269
14270 tempguy.misc10=tempMisc;
14271 }
14272
14273
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&(tempguy.bgsfx),f))
14274 {
14275 return qe_invalid;
14276 }
14277
14278
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&(tempguy.bosspal),f))
14279 {
14280 return qe_invalid;
14281 }
14282
14283
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetw(&(tempguy.extend),f))
14284 {
14285 return qe_invalid;
14286 }
14287
14288 //! Enemy Defences
14289
14290 //If a 2.50 quest, use only the 2.5 defences.
14291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54784 times.
54784 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14292 {
14293
2/2
✓ Branch 0 taken 1040896 times.
✓ Branch 1 taken 54784 times.
1095680 for(int32_t j=0; j<edefLAST; j++)
14294 {
14295
1/2
✓ Branch 0 taken 1040896 times.
✗ Branch 1 not taken.
1040896 if(!p_getc(&(tempguy.defense[j]),f))
14296 {
14297 return qe_invalid;
14298 }
14299 1040896 }
14300 //then copy the generic script defence to all the new script defences
14301
14302 54784 }
14303
14304
14305
14306
14307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54784 times.
54784 if(guyversion >= 18)
14308 {
14309
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_getc(&(tempguy.hitsfx),f))
14310 {
14311 return qe_invalid;
14312 }
14313
14314
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_getc(&(tempguy.deadsfx),f))
14315 {
14316 return qe_invalid;
14317 }
14318 54784 }
14319
14320
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(guyversion >= 22)
14321 {
14322
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetl(&(tempguy.misc11),f))
14323 {
14324 return qe_invalid;
14325 }
14326
14327
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(!p_igetl(&(tempguy.misc12),f))
14328 {
14329 return qe_invalid;
14330 }
14331 54784 }
14332 else if(guyversion >= 19)
14333 {
14334 int16_t tempMisc;
14335
14336 if(!p_igetw(&tempMisc,f))
14337 {
14338 return qe_invalid;
14339 }
14340
14341 tempguy.misc11=tempMisc;
14342
14343 if(!p_igetw(&tempMisc,f))
14344 {
14345 return qe_invalid;
14346 }
14347
14348 tempguy.misc12=tempMisc;
14349 }
14350
14351 //If a 2.54 or later quest, use all of the defences.
14352
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 15360 times.
54784 if(guyversion > 24) // Add new guyversion conditional statement
14353 {
14354
2/2
✓ Branch 0 taken 337920 times.
✓ Branch 1 taken 15360 times.
353280 for(int32_t j=edefLAST; j<edefLAST255; j++)
14355 {
14356
1/2
✓ Branch 0 taken 337920 times.
✗ Branch 1 not taken.
337920 if(!p_getc(&(tempguy.defense[j]),f))
14357 {
14358 return qe_invalid;
14359 }
14360 337920 }
14361 15360 }
14362
14363
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 39424 times.
54784 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14364 {
14365
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 39424 times.
433664 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14366 {
14367 394240 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14368 394240 }
14369 39424 }
14370
14371 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14372
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 15360 times.
54784 if(guyversion > 25)
14373 {
14374
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.txsz),f))
14375 {
14376 return qe_invalid;
14377 }
14378
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.tysz),f))
14379 {
14380 return qe_invalid;
14381 }
14382
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.hxsz),f))
14383 {
14384 return qe_invalid;
14385 }
14386
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.hysz),f))
14387 {
14388 return qe_invalid;
14389 }
14390
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.hzsz),f))
14391 {
14392 return qe_invalid;
14393 }
14394 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14395
14396 */
14397 15360 }
14398 //More Enemy Editor vars for 2.60
14399
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 15360 times.
54784 if(guyversion > 26)
14400 {
14401
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.hxofs),f))
14402 {
14403 return qe_invalid;
14404 }
14405
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.hyofs),f))
14406 {
14407 return qe_invalid;
14408 }
14409
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.xofs),f))
14410 {
14411 return qe_invalid;
14412 }
14413
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.yofs),f))
14414 {
14415 return qe_invalid;
14416 }
14417
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.zofs),f))
14418 {
14419 return qe_invalid;
14420 }
14421 15360 }
14422
14423
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 39424 times.
54784 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14424 {
14425 39424 tempguy.wpnsprite = 0;
14426 39424 }
14427
14428
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 15360 times.
54784 if(guyversion > 27)
14429 {
14430
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.wpnsprite),f))
14431 {
14432 return qe_invalid;
14433 }
14434 15360 }
14435
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 39424 times.
54784 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14436 {
14437 39424 tempguy.SIZEflags = 0;
14438 39424 }
14439
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 15360 times.
54784 if(guyversion > 28)
14440 {
14441
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.SIZEflags),f))
14442 {
14443 return qe_invalid;
14444 }
14445
14446 15360 }
14447
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 39424 times.
54784 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14448 {
14449 39424 tempguy.frozentile = 0;
14450 39424 tempguy.frozencset = 0;
14451 39424 tempguy.frozenclock = 0;
14452
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 39424 times.
433664 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14453 39424 }
14454
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 15360 times.
54784 if(guyversion >= 30)
14455 {
14456
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.frozentile),f))
14457 {
14458 return qe_invalid;
14459 }
14460
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.frozencset),f))
14461 {
14462 return qe_invalid;
14463 }
14464
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.frozenclock),f))
14465 {
14466 return qe_invalid;
14467 }
14468
2/2
✓ Branch 0 taken 153600 times.
✓ Branch 1 taken 15360 times.
168960 for ( int32_t q = 0; q < 10; q++ ) {
14469
1/2
✓ Branch 0 taken 153600 times.
✗ Branch 1 not taken.
153600 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14470 {
14471 return qe_invalid;
14472 }
14473 153600 }
14474
14475 15360 }
14476
14477
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 15360 times.
54784 if(guyversion >= 34)
14478 {
14479
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetw(&(tempguy.firesfx),f))
14480 {
14481 return qe_invalid;
14482 }
14483
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc16),f))
14484 {
14485 return qe_invalid;
14486 }
14487
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc17),f))
14488 {
14489 return qe_invalid;
14490 }
14491
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc18),f))
14492 {
14493 return qe_invalid;
14494 }
14495
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc19),f))
14496 {
14497 return qe_invalid;
14498 }
14499
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc20),f))
14500 {
14501 return qe_invalid;
14502 }
14503
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc21),f))
14504 {
14505 return qe_invalid;
14506 }
14507
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc22),f))
14508 {
14509 return qe_invalid;
14510 }
14511
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc23),f))
14512 {
14513 return qe_invalid;
14514 }
14515
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc24),f))
14516 {
14517 return qe_invalid;
14518 }
14519
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc25),f))
14520 {
14521 return qe_invalid;
14522 }
14523
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc26),f))
14524 {
14525 return qe_invalid;
14526 }
14527
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc27),f))
14528 {
14529 return qe_invalid;
14530 }
14531
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc28),f))
14532 {
14533 return qe_invalid;
14534 }
14535
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc29),f))
14536 {
14537 return qe_invalid;
14538 }
14539
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc30),f))
14540 {
14541 return qe_invalid;
14542 }
14543
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc31),f))
14544 {
14545 return qe_invalid;
14546 }
14547
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc32),f))
14548 {
14549 return qe_invalid;
14550 }
14551
14552
2/2
✓ Branch 0 taken 491520 times.
✓ Branch 1 taken 15360 times.
506880 for ( int32_t q = 0; q < 32; q++ ) {
14553
1/2
✓ Branch 0 taken 491520 times.
✗ Branch 1 not taken.
491520 if(!p_igetl(&(tempguy.movement[q]),f))
14554 {
14555 return qe_invalid;
14556 }
14557 491520 }
14558
2/2
✓ Branch 0 taken 491520 times.
✓ Branch 1 taken 15360 times.
506880 for ( int32_t q = 0; q < 32; q++ ) {
14559
1/2
✓ Branch 0 taken 491520 times.
✗ Branch 1 not taken.
491520 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14560 {
14561 return qe_invalid;
14562 }
14563 491520 }
14564
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetw(&(tempguy.script),f))
14565 {
14566 return qe_invalid;
14567 }
14568 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14569
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 15360 times.
138240 for ( int32_t q = 0; q < 8; q++ )
14570 {
14571
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if(!p_igetl(&(tempguy.initD[q]),f))
14572 {
14573 return qe_invalid;
14574 }
14575 122880 }
14576
2/2
✓ Branch 0 taken 30720 times.
✓ Branch 1 taken 15360 times.
46080 for ( int32_t q = 0; q < 2; q++ )
14577 {
14578
1/2
✓ Branch 0 taken 30720 times.
✗ Branch 1 not taken.
30720 if(!p_igetl(&(tempguy.initA[q]),f))
14579 {
14580 return qe_invalid;
14581 }
14582 30720 }
14583
14584 15360 }
14585
14586
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 15360 times.
54784 if(guyversion >= 37)
14587 {
14588
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.editorflags),f))
14589 {
14590 return qe_invalid;
14591 }
14592 15360 }
14593
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 39424 times.
54784 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14594
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 15360 times.
54784 if(guyversion >= 38)
14595 {
14596
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc13),f))
14597 {
14598 return qe_invalid;
14599 }
14600
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc14),f))
14601 {
14602 return qe_invalid;
14603 }
14604
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc15),f))
14605 {
14606 return qe_invalid;
14607 }
14608
14609 15360 }
14610
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 39424 times.
54784 if ( guyversion < 38 )
14611 {
14612 39424 tempguy.misc13 = 0;
14613 39424 tempguy.misc14 = 0;
14614 39424 tempguy.misc15 = 0;
14615 39424 }
14616
14617
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 15360 times.
54784 if ( guyversion >= 39 )
14618 {
14619
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 15360 times.
138240 for ( int32_t q = 0; q < 8; q++ )
14620 {
14621
2/2
✓ Branch 0 taken 7987200 times.
✓ Branch 1 taken 122880 times.
8110080 for ( int32_t w = 0; w < 65; w++ )
14622 {
14623
1/2
✓ Branch 0 taken 7987200 times.
✗ Branch 1 not taken.
7987200 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14624 {
14625 return qe_invalid;
14626 }
14627 7987200 }
14628
2/2
✓ Branch 0 taken 7987200 times.
✓ Branch 1 taken 122880 times.
8110080 for ( int32_t w = 0; w < 65; w++ )
14629 {
14630
1/2
✓ Branch 0 taken 7987200 times.
✗ Branch 1 not taken.
7987200 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f))
14631 {
14632 return qe_invalid;
14633 }
14634 7987200 }
14635 122880 }
14636
14637
14638 15360 }
14639
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 39424 times.
54784 if ( guyversion < 39 ) //apply old InitD strings to both
14640 {
14641
2/2
✓ Branch 0 taken 315392 times.
✓ Branch 1 taken 39424 times.
354816 for ( int32_t q = 0; q < 8; q++ )
14642 {
14643 315392 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14644 315392 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14645 315392 }
14646 39424 }
14647
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 15360 times.
54784 if ( guyversion >= 40 )
14648 {
14649
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetw(&(tempguy.weaponscript),f))
14650 {
14651 return qe_invalid;
14652 }
14653 15360 }
14654
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 39424 times.
54784 if ( guyversion < 40 )
14655 {
14656 39424 tempguy.weaponscript = 0;
14657 39424 }
14658 //eweapon script InitD
14659
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 15360 times.
54784 if ( guyversion >= 41 )
14660 {
14661
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 15360 times.
138240 for ( int32_t q = 0; q < 8; q++ )
14662 {
14663
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if(!p_igetl(&(tempguy.weap_initiald[q]),f))
14664 {
14665 return qe_invalid;
14666 }
14667 122880 }
14668
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if ( guy_cversion < 4 )
14669 {
14670 if ( tempguy.family == eeKEESE )
14671 {
14672
14673 if ( !tempguy.misc1 )
14674 {
14675 tempguy.misc16 = 120;
14676 tempguy.misc17 = 16;
14677
14678 }
14679 }
14680 if ( tempguy.family == eePEAHAT )
14681 {
14682 tempguy.misc16 = 80;
14683 tempguy.misc17 = 16;
14684 }
14685
14686 if ( tempguy.family == eeGHINI )
14687 {
14688 tempguy.misc16 = 120;
14689 tempguy.misc17 = 10;
14690 }
14691
14692 }
14693 15360 }
14694
14695
14696
14697 //default weapon sprites (quest version < 2.54)
14698 //port over old defaults -Z
14699
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 39424 times.
54784 if(guyversion < 32)
14700 {
14701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39424 times.
39424 if ( tempguy.wpnsprite <= 0 )
14702 {
14703
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32842 times.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 314 times.
✓ Branch 6 taken 931 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 912 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 137 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 363 times.
✓ Branch 14 taken 759 times.
✓ Branch 15 taken 106 times.
✓ Branch 16 taken 80 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 765 times.
39424 switch(tempguy.weapon)
14704 {
14705 case wNone:
14706 32842 tempguy.wpnsprite = 0; break;
14707
14708 case wSword:
14709 case wBeam:
14710 case wBrang:
14711 case wBomb:
14712 case wSBomb:
14713 case wLitBomb:
14714 case wLitSBomb:
14715 case wArrow:
14716 case wFire:
14717 case wWhistle:
14718 case wBait:
14719 case wWand:
14720 case wMagic:
14721 case wCatching:
14722 case wWind:
14723 case wRefMagic:
14724 case wRefFireball:
14725 case wRefRock:
14726 case wHammer:
14727 case wHookshot:
14728 case wHSHandle:
14729 case wHSChain:
14730 case wSSparkle:
14731 case wFSparkle:
14732 case wSmack:
14733 case wPhantom:
14734 case wCByrna:
14735 case wRefBeam:
14736 case wStomp:
14737 case lwMax:
14738 case wScript1:
14739 case wScript2:
14740 case wScript3:
14741 case wScript4:
14742 case wScript5:
14743 case wScript6:
14744 case wScript7:
14745 case wScript8:
14746 case wScript9:
14747 case wScript10:
14748 case wIce:
14749 //Cannot use any of these weapons yet.
14750 tempguy.wpnsprite = -1;
14751 break;
14752
14753 case wEnemyWeapons:
14754 1303 case ewFireball: tempguy.wpnsprite = 17; break;
14755
14756 302 case ewArrow: tempguy.wpnsprite = 19; break;
14757 314 case ewBrang: tempguy.wpnsprite = 4; break;
14758 931 case ewSword: tempguy.wpnsprite = 20; break;
14759 493 case ewRock: tempguy.wpnsprite = 18; break;
14760 912 case ewMagic: tempguy.wpnsprite = 21; break;
14761 80 case ewBomb: tempguy.wpnsprite = 78; break;
14762 18 case ewSBomb: tempguy.wpnsprite = 79; break;
14763 137 case ewLitBomb: tempguy.wpnsprite = 76; break;
14764 19 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14765 363 case ewFireTrail: tempguy.wpnsprite = 80; break;
14766 759 case ewFlame: tempguy.wpnsprite = 35; break;
14767 106 case ewWind: tempguy.wpnsprite = 36; break;
14768 80 case ewFlame2: tempguy.wpnsprite = 81; break;
14769 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14770 case ewIce: tempguy.wpnsprite = 83; break;
14771 765 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14772
14773
14774 default: break; //No assign.
14775 }
14776 39424 }
14777 39424 }
14778
14779 //default weapon fire sound (quest version < 2.54)
14780 //port over old defaults and zero new data. -Z
14781
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 39424 times.
54784 if(guyversion < 34)
14782 {
14783
2/2
✓ Branch 0 taken 1261568 times.
✓ Branch 1 taken 39424 times.
1300992 for ( int32_t q = 0; q < 32; q++ )
14784 {
14785 1261568 tempguy.movement[q] = 0;
14786 1261568 tempguy.new_weapon[q] = 0;
14787
14788 1261568 }
14789
14790 //NPC Script attributes.
14791 39424 tempguy.script = 0; //No scripted enemies existed. -Z
14792
2/2
✓ Branch 0 taken 315392 times.
✓ Branch 1 taken 39424 times.
354816 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14793
2/2
✓ Branch 0 taken 78848 times.
✓ Branch 1 taken 39424 times.
118272 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14794
14795 39424 tempguy.misc16 = 0;
14796 39424 tempguy.misc17 = 0;
14797 39424 tempguy.misc18 = 0;
14798 39424 tempguy.misc19 = 0;
14799 39424 tempguy.misc20 = 0;
14800 39424 tempguy.misc21 = 0;
14801 39424 tempguy.misc22 = 0;
14802 39424 tempguy.misc23 = 0;
14803 39424 tempguy.misc24 = 0;
14804 39424 tempguy.misc25 = 0;
14805 39424 tempguy.misc26 = 0;
14806 39424 tempguy.misc27 = 0;
14807 39424 tempguy.misc28 = 0;
14808 39424 tempguy.misc29 = 0;
14809 39424 tempguy.misc30 = 0;
14810 39424 tempguy.misc31 = 0;
14811 39424 tempguy.misc32 = 0;
14812
14813 //old default sounds
14814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39424 times.
39424 if ( tempguy.firesfx <= 0 )
14815 {
14816
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32842 times.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 314 times.
✓ Branch 6 taken 931 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 912 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 137 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 363 times.
✓ Branch 14 taken 759 times.
✓ Branch 15 taken 106 times.
✓ Branch 16 taken 80 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 765 times.
39424 switch(tempguy.weapon)
14817 {
14818 case wNone:
14819 32842 tempguy.firesfx = 0; break;
14820
14821 case wSword:
14822 case wBeam:
14823 case wBrang:
14824 case wBomb:
14825 case wSBomb:
14826 case wLitBomb:
14827 case wLitSBomb:
14828 case wArrow:
14829 case wFire:
14830 case wWhistle:
14831 case wBait:
14832 case wWand:
14833 case wMagic:
14834 case wCatching:
14835 case wWind:
14836 case wRefMagic:
14837 case wRefFireball:
14838 case wRefRock:
14839 case wHammer:
14840 case wHookshot:
14841 case wHSHandle:
14842 case wHSChain:
14843 case wSSparkle:
14844 case wFSparkle:
14845 case wSmack:
14846 case wPhantom:
14847 case wCByrna:
14848 case wRefBeam:
14849 case wStomp:
14850 case lwMax:
14851 case wScript1:
14852 case wScript2:
14853 case wScript3:
14854 case wScript4:
14855 case wScript5:
14856 case wScript6:
14857 case wScript7:
14858 case wScript8:
14859 case wScript9:
14860 case wScript10:
14861 case wIce:
14862 //Cannot use any of these weapons yet.
14863 tempguy.firesfx = -1;
14864 break;
14865
14866 case wEnemyWeapons:
14867 1303 case ewFireball: tempguy.firesfx = 40; break;
14868
14869 302 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14870 314 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14871 931 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14872 493 case ewRock: tempguy.firesfx = 51; break;
14873 912 case ewMagic: tempguy.firesfx = 32; break;
14874 80 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14875 18 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14876 137 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14877 19 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14878 363 case ewFireTrail: tempguy.firesfx = 13; break;
14879 759 case ewFlame: tempguy.firesfx = 13; break;
14880 106 case ewWind: tempguy.firesfx = 32; break;
14881 80 case ewFlame2: tempguy.firesfx = 13; break;
14882 case ewFlame2Trail: tempguy.firesfx = 13; break;
14883 case ewIce: tempguy.firesfx = 44; break;
14884 765 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14885
14886 //what about special attacks (e.g. summoning == 56)
14887 default: break; //No assign.
14888 }
14889 39424 }
14890 39424 }
14891
14892 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14893
4/6
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 39424 times.
✓ Branch 2 taken 15360 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 15360 times.
54784 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14894 {
14895
2/2
✓ Branch 0 taken 3549 times.
✓ Branch 1 taken 35875 times.
39424 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14896 39424 }
14897 //Keese and bat halt rates.
14898
3/4
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 15360 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39424 times.
54784 if ( guyversion < 42 && guy_cversion < 4 )
14899 {
14900
14901
2/2
✓ Branch 0 taken 38895 times.
✓ Branch 1 taken 529 times.
39424 if ( tempguy.family == eeKEESE )
14902 {
14903
14904
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 326 times.
529 if ( !tempguy.misc1 )
14905 {
14906 326 tempguy.misc16 = 120;
14907 326 tempguy.misc17 = 16;
14908
14909 326 }
14910 529 }
14911
2/2
✓ Branch 0 taken 39257 times.
✓ Branch 1 taken 167 times.
39424 if ( tempguy.family == eePEAHAT )
14912 {
14913 167 tempguy.misc16 = 80;
14914 167 tempguy.misc17 = 16;
14915 167 }
14916
2/2
✓ Branch 0 taken 39347 times.
✓ Branch 1 taken 77 times.
39424 if ( tempguy.family == eeGHINI )
14917 {
14918 77 tempguy.misc16 = 120;
14919 77 tempguy.misc17 = 10;
14920 77 }
14921
14922
14923 39424 }
14924
14925
14926 //miscellaneous other corrections
14927 //fix the mirror wizzrobe -DD
14928
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(guyversion < 7)
14929 {
14930 if(i == eMWIZ)
14931 {
14932 tempguy.misc2 = 0;
14933 tempguy.misc4 = 1;
14934 }
14935 }
14936
14937
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(guyversion < 8)
14938 {
14939 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14940 {
14941 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14942 tempguy.misc5 = 4; //neck length in segments
14943 tempguy.misc6 = 8; //neck offset from first body tile
14944 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
14945 tempguy.misc8 = 168; //head offset from first body tile
14946 tempguy.misc9 = 228; //flying head offset from first body tile
14947
14948 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14949 {
14950 tempguy.misc6 += 10; //neck offset from first body tile
14951 tempguy.misc8 -= 12; //head offset from first body tile
14952 }
14953 }
14954 }
14955
14956
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14957 {
14958 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
14959 tempguy.bosspal = spDIG;
14960 }
14961
14962
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(guyversion < 11) // December 2007 - Spinning Tile fix
14963 {
14964 if(tempguy.family==eeSPINTILE)
14965 {
14966 tempguy.flags |= guy_superman;
14967 tempguy.item_set = 0; // Don't drop items
14968 tempguy.step = 300;
14969 }
14970 }
14971
14972
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14973 {
14974 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14975 {
14976 if(tempguy.family==eeROPE)
14977 {
14978 tempguy.flags2 &= ~guy_flashing;
14979 }
14980 }
14981
14982 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14983 {
14984 if(tempguy.family==eeBUBBLE)
14985 {
14986 tempguy.flags2 &= ~guy_flashing;
14987 }
14988 }
14989
14990 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
14991 {
14992 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14993 {
14994 tempguy.flags2 |= guy_blinking;
14995 }
14996
14997 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14998 {
14999 tempguy.flags2 |= guy_transparent;
15000 }
15001 }
15002 }
15003
15004
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
15005 {
15006 if(i==gFIRE)
15007 {
15008 tempguy.e_anim = aFLIP;
15009 tempguy.e_frate = 24;
15010 }
15011
15012 if(i==gFAIRY)
15013 {
15014 tempguy.e_anim = a2FRM;
15015 tempguy.e_frate = 16;
15016 }
15017 }
15018
15019
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
15020 {
15021 if(i==0) Z_message("Updating guys to version 16...\n");
15022
15023 update_guy_1(&tempguy);
15024
15025 if(i==eMPOLSV)
15026 {
15027 tempguy.defense[edefARROW] = edCHINK;
15028 tempguy.defense[edefMAGIC] = ed1HKO;
15029 tempguy.defense[edefREFMAGIC] = ed1HKO;
15030 }
15031 }
15032
15033
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(guyversion < 17) // December 2009
15034 {
15035 if(tempguy.family==eePROJECTILE)
15036 {
15037 tempguy.misc1 = 0;
15038 }
15039 }
15040
15041
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(guyversion < 18) // January 2010
15042 {
15043 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
15044 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
15045
15046 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
15047 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
15048
15049 if(tempguy.family == eeAQUA)
15050 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
15051 else if(tempguy.family == eeMANHAN)
15052 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
15053 else if(tempguy.family==eePATRA)
15054 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15055 else if(tempguy.family==eeGHOMA)
15056 {
15057 for(int32_t j=0; j<edefLAST; j++)
15058 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15059
15060 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
15061
15062 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15063
15064 tempguy.misc1--;
15065 }
15066 else if(tempguy.family == eeGLEEOK)
15067 {
15068 for(int32_t j=0; j<edefLAST; j++)
15069 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15070
15071 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15072 }
15073 else if(tempguy.family == eeARMOS)
15074 {
15075 tempguy.family=eeWALK;
15076 tempguy.hrate = 0;
15077 tempguy.misc10 = tempguy.misc1;
15078 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
15079 tempguy.misc9 = e9tARMOS;
15080 }
15081 else if(tempguy.family == eeGHINI && !tempguy.misc1)
15082 {
15083 tempguy.family=eeWALK;
15084 tempguy.hrate = 0;
15085 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
15086 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
15087 }
15088
15089 // Spawn animation flags
15090 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
15091 tempguy.flags |= guy_fadeflicker;
15092 else
15093 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
15094 }
15095
15096
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(guyversion < 20) // April 2010
15097 {
15098 if(tempguy.family == eeTRAP)
15099 {
15100 tempguy.misc2 = tempguy.misc10;
15101
15102 if(tempguy.misc10>=1)
15103 {
15104 tempguy.misc1++;
15105 }
15106
15107 tempguy.misc10 = 0;
15108 }
15109
15110 // Bomb Blast fix
15111 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15112 tempguy.weapon = ewLitBomb;
15113 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15114 tempguy.weapon = ewLitSBomb;
15115 }
15116
15117
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(guyversion < 21) // September 2011
15118 {
15119 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
15120 {
15121 if(tempguy.family == eeKEESETRIB)
15122 {
15123 tempguy.family = eeKEESE;
15124 tempguy.misc2 = e2tKEESETRIB;
15125 tempguy.misc1 = 0;
15126 }
15127
15128 tempguy.rate = 2;
15129 tempguy.hrate = 8;
15130 tempguy.homing = 0;
15131 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
15132 }
15133 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
15134 {
15135 if(tempguy.family == eePEAHAT)
15136 {
15137 tempguy.rate = 4;
15138 tempguy.step = 62;
15139 }
15140 else
15141 tempguy.step = 25;
15142
15143 tempguy.hrate = 8;
15144 tempguy.homing = 0;
15145 }
15146 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
15147 {
15148 if(tempguy.family == eeMANHAN)
15149 tempguy.step=50;
15150
15151 tempguy.hrate = 16;
15152 tempguy.homing = 0;
15153 }
15154 else if(tempguy.family == eeGLEEOK)
15155 {
15156 tempguy.rate = 2;
15157 tempguy.homing = 0;
15158 tempguy.hrate = 9;
15159 tempguy.step=89;
15160 }
15161 else if(tempguy.family == eeGHINI)
15162 {
15163 tempguy.rate = 4;
15164 tempguy.hrate = 12;
15165 tempguy.step=62;
15166 tempguy.homing = 0;
15167 }
15168
15169 // Bigdig random rate fix
15170 if(tempguy.family==eeDIG && tempguy.misc10==1)
15171 {
15172 tempguy.rate = 2;
15173 }
15174 }
15175
15176
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if(guyversion < 24) // November 2012
15177 {
15178 if(tempguy.family==eeLANM)
15179 tempguy.misc3 = 1;
15180 else if(tempguy.family==eeMOLD)
15181 tempguy.misc2 = 0;
15182 }
15183
15184
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 39424 times.
54784 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15185 {
15186
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 38764 times.
39424 if(tempguy.family!=eeDIG)
15187 {
15188 38764 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15189 38764 }
15190
15191 39424 }
15192 // does not seem to solve the issue!
15193
1/2
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
54784 if ( Header->zelda_version <= 0x210 )
15194 {
15195 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15196 if ( tempguy.family == eeDONGO )
15197 {
15198 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15199 }
15200 }
15201
15202
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 39424 times.
54784 if(guyversion >= 42)
15203 {
15204
2/2
✓ Branch 0 taken 14336 times.
✓ Branch 1 taken 1024 times.
15360 if(guyversion >= 47)
15205 {
15206
1/2
✓ Branch 0 taken 14336 times.
✗ Branch 1 not taken.
14336 if(!p_igetl(&(tempguy.moveflags),f))
15207 {
15208 return qe_invalid;
15209 }
15210 14336 }
15211 else
15212 {
15213 byte fl;
15214
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&fl,f))
15215 {
15216 return qe_invalid;
15217 }
15218 1024 tempguy.moveflags = fl;
15219 }
15220 15360 }
15221 else
15222 {
15223
7/8
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 30899 times.
✓ Branch 2 taken 1202 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 518 times.
✓ Branch 5 taken 278 times.
✓ Branch 6 taken 241 times.
✓ Branch 7 taken 5840 times.
39424 switch(tempguy.family)
15224 {
15225 //No gravity; floats over pits
15226 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15227 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15228 //Special (bosses, etc)
15229 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15230 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15231 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15232 30899 tempguy.moveflags = FLAG_CAN_PITWALK;
15233 30899 break;
15234 //No gravity, but falls in pits
15235 case eeLEV:
15236 518 tempguy.moveflags = FLAG_CAN_PITFALL;
15237 518 break;
15238 //Bosses that respect pits
15239 case eeDONGO:
15240 278 tempguy.moveflags = FLAG_OBEYS_GRAV;
15241 278 break;
15242 case eeLANM:
15243 241 tempguy.moveflags = 0;
15244 241 break;
15245 //Gravity, floats over pits
15246 case eeWIZZ: case eeWALLM: case eeGHINI:
15247 1202 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
15248 1202 break;
15249 //Gravity and falls in pits
15250 case eeWALK:
15251
4/4
✓ Branch 0 taken 5519 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 280 times.
✓ Branch 3 taken 5239 times.
5840 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
15252 601 break;
15253 [[fallthrough]];
15254 case eeOTHER:
15255 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15256 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15257 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15258 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15259 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15260 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15261 5685 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
15262 5685 }
15263 }
15264
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 39424 times.
54784 if(guyversion < 43)
15265 {
15266
2/2
✓ Branch 0 taken 32101 times.
✓ Branch 1 taken 7323 times.
39424 switch(tempguy.family)
15267 {
15268 //No gravity; floats over pits
15269 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15270 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15271 //Special (bosses, etc)
15272 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15273 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15274 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15275 case eeWIZZ: case eeWALLM: case eeGHINI:
15276 //Gravity, floats over pits
15277 32101 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15278 32101 break;
15279 }
15280 39424 }
15281
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 39424 times.
54784 if (guyversion < 44)
15282 {
15283
2/2
✓ Branch 0 taken 39054 times.
✓ Branch 1 taken 370 times.
39424 if ( tempguy.family == eeGHOMA )
15284 {
15285 370 tempguy.flags |= guy_fadeinstant;
15286 370 }
15287 39424 }
15288
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 39424 times.
54784 if (guyversion > 44)
15289 {
15290
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_getc(&(tempguy.spr_shadow),f))
15291 {
15292 return qe_invalid;
15293 }
15294
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_getc(&(tempguy.spr_death),f))
15295 {
15296 return qe_invalid;
15297 }
15298
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_getc(&(tempguy.spr_spawn),f))
15299 {
15300 return qe_invalid;
15301 }
15302 15360 }
15303 else
15304 {
15305
2/2
✓ Branch 0 taken 39271 times.
✓ Branch 1 taken 153 times.
39424 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15306 39424 tempguy.spr_death = iwDeath;
15307 39424 tempguy.spr_spawn = iwSpawn;
15308 }
15309
15310
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 39424 times.
54784 if(guyversion < 46)
15311 {
15312
4/4
✓ Branch 0 taken 5840 times.
✓ Branch 1 taken 33584 times.
✓ Branch 2 taken 5519 times.
✓ Branch 3 taken 321 times.
39424 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15313 {
15314 321 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15315 321 }
15316 39424 }
15317
15318 54784 guysbuf[i] = tempguy;
15319 54784 }
15320 107 }
15321
15322 107 return 0;
15323 123 }
15324
15325 void update_guy_1(guydata *tempguy) // November 2009
15326 {
15327 bool doesntcount = false;
15328 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15329
15330 switch(tempguy->family)
15331 {
15332 case 1: //eeWALK
15333 switch(tempguy->misc10)
15334 {
15335 case 0: //Stalfos
15336 if(tempguy->misc1==1) // Fires four projectiles at once
15337 tempguy->misc1=4;
15338
15339 break;
15340
15341 case 1: //Darknut
15342 goto darknuts;
15343 break;
15344 }
15345
15346 tempguy->misc10 = 0;
15347 break;
15348
15349 case 2: //eeSHOOT
15350 tempguy->family = eeWALK;
15351
15352 switch(tempguy->misc10)
15353 {
15354 case 0: //Octorok
15355 if(tempguy->misc1==1||tempguy->misc1==2)
15356 {
15357 tempguy->misc1=e1tFIREOCTO;
15358 tempguy->misc2=e2tFIREOCTO;
15359 }
15360 else tempguy->misc1 = 0;
15361
15362 tempguy->misc6=tempguy->misc4;
15363 tempguy->misc4=tempguy->misc3;
15364 tempguy->misc3=0;
15365 break;
15366
15367 case 1: // Moblin
15368 tempguy->misc1 = 0;
15369 break;
15370
15371 case 2: //Lynel
15372 tempguy->misc6=tempguy->misc1+1;
15373 tempguy->misc1=0;
15374 break;
15375
15376 case 3: //Stalfos 2
15377 if(tempguy->misc1==1) // Fires four projectiles at once
15378 tempguy->misc1=e1t4SHOTS;
15379 else tempguy->misc1 = 0;
15380
15381 break;
15382
15383 case 4: //Darknut 5
15384 darknuts:
15385 tempguy->defense[edefFIRE] = edIGNORE;
15386 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15387 tempguy->defense[edefHOOKSHOT] = 0;
15388 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15389 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15390
15391 if(tempguy->misc1==1)
15392 tempguy->misc1=2;
15393 else if(tempguy->misc1==2)
15394 {
15395 tempguy->misc4=tempguy->misc3;
15396 tempguy->misc3=tempguy->misc2;
15397 tempguy->misc2=e2tSPLIT;
15398 tempguy->misc1 = 0;
15399 }
15400 else tempguy->misc1 = 0;
15401
15402 tempguy->flags |= inv_front;
15403
15404 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15405 tempguy->flags |= guy_bkshield;
15406
15407 break;
15408 }
15409
15410 tempguy->misc10 = 0;
15411 break;
15412
15413 /*
15414 case 9: //eeARMOS
15415 tempguy->family = eeWALK;
15416 break;
15417 */
15418 case 11: //eeGEL
15419 case 33: //eeGELTRIB
15420 if(tempguy->family==33)
15421 {
15422 tempguy->misc4 = 1;
15423
15424 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15425 tempguy->misc3 = tempguy->misc2;
15426
15427 tempguy->misc2 = e2tTRIBBLE;
15428 }
15429 else
15430 {
15431 tempguy->misc4 = 0;
15432 tempguy->misc3 = 0;
15433 tempguy->misc2 = 0;
15434 }
15435
15436 tempguy->family = eeWALK;
15437
15438 if(tempguy->misc1)
15439 {
15440 tempguy->misc1=1;
15441 tempguy->weapon = ewFireTrail;
15442 }
15443
15444 break;
15445
15446 case 34: //eeZOLTRIB
15447 case 12: //eeZOL
15448 tempguy->misc4=tempguy->misc3;
15449 tempguy->misc3=tempguy->misc2;
15450 tempguy->family = eeWALK;
15451 tempguy->misc2=e2tSPLITHIT;
15452
15453 if(tempguy->misc1)
15454 {
15455 tempguy->misc1=1;
15456 tempguy->weapon = ewFireTrail;
15457 }
15458
15459 break;
15460
15461 case 13: //eeROPE
15462 tempguy->family = eeWALK;
15463 tempguy->misc9 = e9tROPE;
15464
15465 if(tempguy->misc1)
15466 {
15467 tempguy->misc4 = tempguy->misc3;
15468 tempguy->misc3 = tempguy->misc2;
15469 tempguy->misc2 = e2tBOMBCHU;
15470 }
15471
15472 tempguy->misc1 = 0;
15473 break;
15474
15475 case 14: //eeGORIYA
15476 tempguy->family = eeWALK;
15477
15478 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15479
15480 break;
15481
15482 case 17: //eeBUBBLE
15483 tempguy->family = eeWALK;
15484 tempguy->misc8 = tempguy->misc2;
15485 tempguy->misc7 = tempguy->misc1 + 1;
15486 tempguy->misc1 = tempguy->misc2 = 0;
15487
15488 //fallthrogh
15489 case eeTRAP:
15490 case eeROCK:
15491 doesntcount = true;
15492 break;
15493
15494 case 35: //eeVIRETRIB
15495 case 18: //eeVIRE
15496 tempguy->family = eeWALK;
15497 tempguy->misc4=tempguy->misc3;
15498 tempguy->misc3=tempguy->misc2;
15499 tempguy->misc2=e2tSPLITHIT;
15500 tempguy->misc9=e9tVIRE;
15501 break;
15502
15503 case 19: //eeLIKE
15504 tempguy->family = eeWALK;
15505 tempguy->misc7 = e7tEATITEMS;
15506 tempguy->misc8=95;
15507 break;
15508
15509 case 20: //eePOLSV
15510 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15511 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15512 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15513 tempguy->defense[edefARROW] = ed1HKO;
15514 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15515 tempguy->family = eeWALK;
15516 tempguy->misc9 = e9tPOLSVOICE;
15517 tempguy->rate = 4;
15518 tempguy->homing = 32;
15519 tempguy->hrate = 10;
15520 tempguy->grumble = 0;
15521 break;
15522
15523 case eeWIZZ:
15524 if(tempguy->misc4)
15525 {
15526 for(int32_t i=0; i < edefLAST; i++)
15527 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15528 }
15529 else
15530 {
15531 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15532 tempguy->defense[edefMAGIC] = edCHINK;
15533 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15534 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15535 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15536 }
15537
15538 break;
15539
15540 case eePEAHAT:
15541 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15542
15543 if(!(tempguy->flags & guy_bhit))
15544 tempguy->defense[edefBRANG] = edSTUNONLY;
15545
15546 break;
15547
15548 case eeLEV:
15549 tempguy->defense[edefSTOMP] = edCHINK;
15550 break;
15551 }
15552
15553 // Old flags
15554 if(tempguy->flags & guy_superman)
15555 {
15556 for(int32_t i = 0; i < edefLAST; i++)
15557 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15558 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15559 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15560 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15561 }
15562
15563 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15564
15565 if(doesntcount)
15566 tempguy->flags |= (guy_doesntcount);
15567 }
15568
15569
15570 247176 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
15571 {
15572 byte tempbyte, padding;
15573 int32_t extras, secretcombos;
15574 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->valid),f))
15576 {
15577 return qe_invalid;
15578 }
15579
15580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->guy),f))
15581 return qe_invalid;
15582 247176 temp_mapscr->guytile = -1; //signal to use default guy values
15583
2/2
✓ Branch 0 taken 246700 times.
✓ Branch 1 taken 476 times.
247176 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15584
4/4
✓ Branch 0 taken 476 times.
✓ Branch 1 taken 246700 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 453 times.
247176 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15585
15586
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15587 {
15588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f))
15589 {
15590 return qe_invalid;
15591 }
15592
15593 6864 temp_mapscr->str=tempbyte;
15594 6864 }
15595 else
15596 {
15597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 if(!p_igetw(&(temp_mapscr->str),f))
15598 {
15599 return qe_invalid;
15600 }
15601 }
15602
15603
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->room),f))
15604 {
15605 return qe_invalid;
15606 }
15607
15608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->item),f))
15609 {
15610 return qe_invalid;
15611 }
15612
15613
3/6
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 153408 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15614 {
15615 93768 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15616 93768 }
15617 else
15618 {
15619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->hasitem),f))
15620 return qe_invalid;
15621 }
15622
15623
2/4
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
247176 if((Header->zelda_version < 0x192)||
15624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15625 {
15626
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f))
15627 {
15628 return qe_invalid;
15629 }
15630 6864 }
15631
15632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15633 {
15634 return qe_invalid;
15635 }
15636
15637
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15638 {
15639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f))
15640 {
15641 return qe_invalid;
15642 }
15643 6864 }
15644
15645
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15646 {
15647
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15648 {
15649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15650 {
15651 return qe_invalid;
15652 }
15653 460224 }
15654 153408 }
15655 else
15656 {
15657 93768 temp_mapscr->tilewarptype[1]=0;
15658 93768 temp_mapscr->tilewarptype[2]=0;
15659 93768 temp_mapscr->tilewarptype[3]=0;
15660 }
15661
15662
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15663 {
15664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15665 {
15666 return qe_invalid;
15667 }
15668 240312 }
15669
15670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15671 {
15672 return qe_invalid;
15673 }
15674
15675 247176 temp_mapscr->warpreturnx[1]=0;
15676 247176 temp_mapscr->warpreturnx[2]=0;
15677 247176 temp_mapscr->warpreturnx[3]=0;
15678
15679
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15680 {
15681
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15682 {
15683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15684 {
15685 return qe_invalid;
15686 }
15687 460224 }
15688 153408 }
15689
15690
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15691 {
15692 return qe_invalid;
15693 }
15694
15695 247176 temp_mapscr->warpreturny[1]=0;
15696 247176 temp_mapscr->warpreturny[2]=0;
15697 247176 temp_mapscr->warpreturny[3]=0;
15698
15699
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15700 {
15701
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15702 {
15703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15704 {
15705 return qe_invalid;
15706 }
15707 460224 }
15708
15709
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(version>=18)
15710 {
15711
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15712 {
15713 return qe_invalid;
15714 }
15715 153408 }
15716 else
15717 {
15718 byte temp;
15719
15720 if(!p_getc(&temp,f))
15721 {
15722 return qe_invalid;
15723 }
15724
15725 temp_mapscr->warpreturnc=temp<<8|temp;
15726 }
15727 153408 }
15728
15729
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->stairx),f))
15730
15731 {
15732 return qe_invalid;
15733 }
15734
15735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->stairy),f))
15736 {
15737 return qe_invalid;
15738 }
15739
15740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->itemx),f))
15741 {
15742 return qe_invalid;
15743 }
15744
15745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->itemy),f))
15746 {
15747 return qe_invalid;
15748 }
15749
15750
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version > 15) // February 2009
15751 {
15752
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->color),f))
15753 {
15754 return qe_invalid;
15755 }
15756 153408 }
15757 else
15758 {
15759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93768 times.
93768 if(!p_getc(& tempbyte,f))
15760 {
15761 return qe_invalid;
15762 }
15763
15764 93768 temp_mapscr->color = (word) tempbyte;
15765 }
15766
15767
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->enemyflags),f))
15768 {
15769 return qe_invalid;
15770 }
15771
15772
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
15773 {
15774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988704 times.
988704 if(!p_getc(&(temp_mapscr->door[k]),f))
15775 {
15776 return qe_invalid;
15777
15778 }
15779 988704 }
15780
15781
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version <= 11)
15782 {
15783
1/2
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
93768 if(!p_getc(&(tempbyte),f))
15784 {
15785 return qe_invalid;
15786 }
15787
15788 93768 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15789
15790
2/6
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93768 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15791 {
15792 for(int32_t i=1; i<4; i++)
15793 {
15794 if(!p_getc(&(tempbyte),f))
15795 {
15796 return qe_invalid;
15797 }
15798
15799 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15800 }
15801 }
15802 else
15803 {
15804 93768 temp_mapscr->tilewarpdmap[1]=0;
15805 93768 temp_mapscr->tilewarpdmap[2]=0;
15806 93768 temp_mapscr->tilewarpdmap[3]=0;
15807 }
15808 93768 }
15809 else
15810 {
15811
2/2
✓ Branch 0 taken 613632 times.
✓ Branch 1 taken 153408 times.
767040 for(int32_t i=0; i<4; i++)
15812 {
15813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613632 times.
613632 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15814 {
15815 return qe_invalid;
15816 }
15817 613632 }
15818 }
15819
15820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15821 {
15822 return qe_invalid;
15823 }
15824
15825
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15826 {
15827
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15828 {
15829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15830 {
15831 return qe_invalid;
15832 }
15833 460224 }
15834 153408 }
15835 else
15836 {
15837 93768 temp_mapscr->tilewarpscr[1]=0;
15838 93768 temp_mapscr->tilewarpscr[2]=0;
15839 93768 temp_mapscr->tilewarpscr[3]=0;
15840 }
15841
15842
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version >= 15)
15843 {
15844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15845 {
15846 return qe_invalid;
15847 }
15848 153408 }
15849 else
15850 {
15851 93768 temp_mapscr->tilewarpoverlayflags=0;
15852 }
15853
15854
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->exitdir),f))
15855 {
15856 return qe_invalid;
15857 }
15858
15859
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15860 {
15861
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f))
15862 {
15863 return qe_invalid;
15864 }
15865
15866 6864 }
15867
15868
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15869 {
15870 if(!p_getc(&padding,f))
15871 {
15872 return qe_invalid;
15873 }
15874 }
15875
15876
2/2
✓ Branch 0 taken 2471760 times.
✓ Branch 1 taken 247176 times.
2718936 for(int32_t k=0; k<10; k++)
15877 {
15878 /*
15879 if (!temp_mapscr->enemy[k])
15880 {
15881 continue;
15882 }
15883 */
15884
3/6
✓ Branch 0 taken 2403120 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2403120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2471760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15885 {
15886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68640 times.
68640 if(!p_getc(&tempbyte,f))
15887 {
15888 return qe_invalid;
15889 }
15890
15891 68640 temp_mapscr->enemy[k]=tempbyte;
15892 68640 }
15893 else
15894 {
15895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2403120 times.
2403120 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15896 {
15897 return qe_invalid;
15898 }
15899 }
15900
15901
3/6
✓ Branch 0 taken 2403120 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2403120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2471760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15902 {
15903 //using enumerations here is dangerous
15904 //very easy to break old quests -DD
15905
2/2
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 67852 times.
68640 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15906 {
15907 788 temp_mapscr->enemy[k]+=5;
15908 788 }
15909
2/2
✓ Branch 0 taken 67812 times.
✓ Branch 1 taken 40 times.
67852 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15910 {
15911 40 temp_mapscr->enemy[k]+=1;
15912 40 }
15913 68640 }
15914
15915
2/2
✓ Branch 0 taken 1534080 times.
✓ Branch 1 taken 937680 times.
2471760 if(version < 9)
15916 {
15917
2/2
✓ Branch 0 taken 856505 times.
✓ Branch 1 taken 81175 times.
937680 if(temp_mapscr->enemy[k]>0)
15918 {
15919 81175 temp_mapscr->enemy[k]+=10;
15920 81175 }
15921 937680 }
15922 //don't read in any invalid data
15923
2/2
✓ Branch 0 taken 2471670 times.
✓ Branch 1 taken 90 times.
2471760 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15924 {
15925 90 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15926 90 temp_mapscr->enemy[k] = 0;
15927 90 }
15928 2471760 }
15929
15930
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->pattern),f))
15931 {
15932 return qe_invalid;
15933 }
15934
15935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15936 {
15937 return qe_invalid;
15938 }
15939
15940
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15941 {
15942
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15943 {
15944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15945 {
15946 return qe_invalid;
15947 }
15948 460224 }
15949 153408 }
15950 else
15951 {
15952 93768 temp_mapscr->sidewarptype[1]=0;
15953 93768 temp_mapscr->sidewarptype[2]=0;
15954 93768 temp_mapscr->sidewarptype[3]=0;
15955 }
15956
15957
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version >= 15)
15958 {
15959
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15960 {
15961 return qe_invalid;
15962 }
15963 153408 }
15964 else
15965 {
15966 93768 temp_mapscr->sidewarpoverlayflags=0;
15967 }
15968
15969
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15970 {
15971 return qe_invalid;
15972 }
15973
15974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15975 {
15976 return qe_invalid;
15977 }
15978
15979
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
15980 {
15981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988704 times.
988704 if(!p_getc(&(temp_mapscr->path[k]),f))
15982 {
15983 return qe_invalid;
15984 }
15985 988704 }
15986
15987
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
15988 {
15989 return qe_invalid;
15990 }
15991
15992
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15993 {
15994
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 460224 times.
613632 for(int32_t i=1; i<4; i++)
15995 {
15996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
15997 {
15998 return qe_invalid;
15999 }
16000 460224 }
16001 153408 }
16002 else
16003 {
16004 93768 temp_mapscr->sidewarpscr[1]=0;
16005 93768 temp_mapscr->sidewarpscr[2]=0;
16006 93768 temp_mapscr->sidewarpscr[3]=0;
16007 }
16008
16009
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version <= 11)
16010 {
16011
1/2
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
93768 if(!p_getc(&(tempbyte),f))
16012 {
16013 return qe_invalid;
16014 }
16015
16016 93768 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
16017
16018
2/6
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93768 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16019 {
16020 for(int32_t i=1; i<4; i++)
16021 {
16022 if(!p_getc(&(tempbyte),f))
16023 {
16024 return qe_invalid;
16025 }
16026
16027 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
16028 }
16029 }
16030 else
16031 {
16032 93768 temp_mapscr->sidewarpdmap[1]=0;
16033 93768 temp_mapscr->sidewarpdmap[2]=0;
16034 93768 temp_mapscr->sidewarpdmap[3]=0;
16035 }
16036 93768 }
16037 else
16038 {
16039
2/2
✓ Branch 0 taken 613632 times.
✓ Branch 1 taken 153408 times.
767040 for(int32_t i=0; i<4; i++)
16040 {
16041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613632 times.
613632 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16042 {
16043 return qe_invalid;
16044 }
16045 613632 }
16046 }
16047
16048
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16049 {
16050
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16051 {
16052 return qe_invalid;
16053 }
16054 153408 }
16055 93768 else temp_mapscr->sidewarpindex = 0;
16056
16057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_igetw(&(temp_mapscr->undercombo),f))
16058 {
16059 return qe_invalid;
16060 }
16061
16062
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
16063 {
16064
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&(temp_mapscr->old_cpage),f))
16065 {
16066 return qe_invalid;
16067 }
16068 6864 }
16069
16070
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
16071 {
16072 return qe_invalid;
16073 }
16074
16075
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_igetw(&(temp_mapscr->catchall),f))
16076 {
16077 return qe_invalid;
16078 }
16079
16080
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->flags),f))
16081 {
16082 return qe_invalid;
16083 }
16084
16085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->flags2),f))
16086 {
16087 return qe_invalid;
16088 }
16089
16090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->flags3),f))
16091 {
16092 return qe_invalid;
16093 }
16094
16095
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16096 //if (version>2)
16097 {
16098
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags4),f))
16099 {
16100 return qe_invalid;
16101 }
16102 153408 }
16103
16104
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16105 {
16106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags5),f))
16107 {
16108 return qe_invalid;
16109 }
16110
16111
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->noreset),f))
16112 {
16113 return qe_invalid;
16114 }
16115
16116
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->nocarry),f))
16117 {
16118 return qe_invalid;
16119 }
16120
16121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(temp_mapscr->flags5&32)
16122 {
16123 temp_mapscr->flags5 &= ~32;
16124 temp_mapscr->noreset |= 48;
16125 }
16126
16127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(version<8)
16128 {
16129 if(temp_mapscr->noreset&1)
16130 {
16131 temp_mapscr->noreset|=8192;
16132 }
16133
16134 if(temp_mapscr->nocarry&1)
16135 {
16136 temp_mapscr->nocarry|=8192;
16137 temp_mapscr->nocarry&=~1;
16138 }
16139 }
16140 153408 }
16141 else
16142 {
16143 93768 temp_mapscr->flags5 = 0;
16144 93768 temp_mapscr->noreset = 0;
16145 93768 temp_mapscr->nocarry = 0;
16146 }
16147
16148
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16149 {
16150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags6),f))
16151 {
16152 return qe_invalid;
16153 }
16154 153408 }
16155
16156
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>5)
16157 {
16158
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags7),f))
16159 {
16160 return qe_invalid;
16161 }
16162
16163
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags8),f))
16164 {
16165 return qe_invalid;
16166 }
16167
16168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags9),f))
16169 {
16170 return qe_invalid;
16171 }
16172
16173
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags10),f))
16174 {
16175 return qe_invalid;
16176 }
16177
16178
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->csensitive),f))
16179 {
16180 return qe_invalid;
16181 }
16182 153408 }
16183 else
16184 {
16185 93768 temp_mapscr->csensitive=1;
16186 }
16187
16188
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version<14) // August 2007: screen SFX added
16189 {
16190
2/2
✓ Branch 0 taken 93668 times.
✓ Branch 1 taken 100 times.
93768 if(temp_mapscr->flags&8) //fROAR
16191 {
16192 100 temp_mapscr->bosssfx=
16193
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 91 times.
100 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16194 91 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16195 WAV_ROAR;
16196 100 }
16197
16198
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 93677 times.
93768 if(temp_mapscr->flags&128) //fSEA
16199 {
16200 91 temp_mapscr->oceansfx=WAV_SEA;
16201 91 }
16202
16203 93768 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16204 ? 0 : WAV_SECRET;
16205
16206 93768 temp_mapscr->flags3 &= ~66; //64|2
16207 93768 temp_mapscr->flags2 &= ~32;
16208 93768 temp_mapscr->flags &= ~136; // 128|8
16209 93768 }
16210 else
16211 {
16212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->oceansfx),f))
16213 {
16214 return qe_invalid;
16215 }
16216
16217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->bosssfx),f))
16218 {
16219 return qe_invalid;
16220 }
16221
16222
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->secretsfx),f))
16223 {
16224 return qe_invalid;
16225 }
16226 }
16227
16228
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version<15) // October 2007: another SFX
16229 {
16230 93768 temp_mapscr->holdupsfx=WAV_PICKUP;
16231 93768 }
16232 else
16233 {
16234
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->holdupsfx),f))
16235 {
16236 return qe_invalid;
16237 }
16238 }
16239
16240
16241
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16242 {
16243
2/2
✓ Branch 0 taken 1441872 times.
✓ Branch 1 taken 240312 times.
1682184 for(int32_t k=0; k<6; k++)
16244 {
16245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16246 {
16247 return qe_invalid;
16248 }
16249 1441872 }
16250
16251
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 1441872 times.
1682184 for(int32_t k=0; k<6; k++)
16252 {
16253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16254 {
16255 return qe_invalid;
16256 }
16257 1441872 }
16258 240312 }
16259
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6864 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16260 {
16261 if(!p_getc(&(temp_mapscr->layermap[2]),f))
16262 {
16263 return qe_invalid;
16264 }
16265
16266 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
16267 {
16268 return qe_invalid;
16269 }
16270
16271 if(!p_getc(&(temp_mapscr->layermap[4]),f))
16272 {
16273 return qe_invalid;
16274 }
16275
16276 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
16277
16278 {
16279 return qe_invalid;
16280 }
16281 }
16282
16283
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>149))
16284 {
16285 for(int32_t k=0; k<6; k++)
16286 {
16287 if(!p_getc(&tempbyte,f)) //layerxsize
16288 {
16289 return qe_invalid;
16290 }
16291 }
16292
16293 for(int32_t k=0; k<6; k++)
16294 {
16295 if(!p_getc(&tempbyte,f)) //layerxspeed
16296 {
16297 return qe_invalid;
16298 }
16299 }
16300
16301 for(int32_t k=0; k<6; k++)
16302 {
16303 if(!p_getc(&tempbyte,f)) //layerxdelay
16304 {
16305 return qe_invalid;
16306 }
16307 }
16308
16309 for(int32_t k=0; k<6; k++)
16310 {
16311 if(!p_getc(&tempbyte,f)) //layerysize
16312 {
16313 return qe_invalid;
16314 }
16315 }
16316
16317 for(int32_t k=0; k<6; k++)
16318 {
16319 if(!p_getc(&tempbyte,f)) //layeryspeed
16320 {
16321 return qe_invalid;
16322 }
16323 }
16324
16325 for(int32_t k=0; k<6; k++)
16326 {
16327 if(!p_getc(&tempbyte,f)) //layerydelay
16328 {
16329 return qe_invalid;
16330 }
16331 }
16332 }
16333
16334
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16335 {
16336
2/2
✓ Branch 0 taken 1441872 times.
✓ Branch 1 taken 240312 times.
1682184 for(int32_t k=0; k<6; k++)
16337 {
16338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16339 {
16340 return qe_invalid;
16341 }
16342 1441872 }
16343 240312 }
16344
16345
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16346 {
16347
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 if((Header->zelda_version == 0x192)&&(Header->build>153))
16348 {
16349 if(!p_getc(&padding,f))
16350 {
16351 return qe_invalid;
16352 }
16353 }
16354
16355
1/2
✓ Branch 0 taken 240312 times.
✗ Branch 1 not taken.
240312 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16356 {
16357 return qe_invalid;
16358 }
16359 240312 }
16360
16361
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16362 {
16363 6864 extras=15;
16364 6864 }
16365
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16366 {
16367 extras=11;
16368 }
16369
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16370 {
16371 extras=32;
16372 }
16373
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16374 {
16375 extras=64;
16376 }
16377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 else if(Header->zelda_version < 0x193)
16378 {
16379 extras=62;
16380 }
16381 else
16382
16383 {
16384 240312 extras=0;
16385 }
16386
16387
2/2
✓ Branch 0 taken 102960 times.
✓ Branch 1 taken 247176 times.
350136 for(int32_t k=0; k<extras; k++)
16388 {
16389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102960 times.
102960 if(!p_getc(&tempbyte,f)) //extra[k]
16390 {
16391 return qe_invalid;
16392 }
16393 102960 }
16394
16395
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16396 //if (version>3)
16397 {
16398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->nextmap),f))
16399 {
16400 return qe_invalid;
16401 }
16402
16403
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->nextscr),f))
16404 {
16405 return qe_invalid;
16406 }
16407 153408 }
16408 else
16409 {
16410 93768 temp_mapscr->nextmap=0;
16411 93768 temp_mapscr->nextscr=0;
16412 }
16413
16414
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16415 {
16416 6864 secretcombos=20;
16417 6864 }
16418
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16419 {
16420 secretcombos=256;
16421 }
16422 else
16423 {
16424 240312 secretcombos=128;
16425 }
16426
16427
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16428 {
16429
2/2
✓ Branch 0 taken 137280 times.
✓ Branch 1 taken 6864 times.
144144 for(int32_t k=0; k<secretcombos; k++)
16430 {
16431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(!p_getc(&tempbyte,f))
16432 {
16433 return qe_invalid;
16434 }
16435
16436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(k<128)
16437 {
16438 137280 temp_mapscr->secretcombo[k]=tempbyte;
16439 137280 }
16440 137280 }
16441 6864 }
16442 else
16443 {
16444
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16445 {
16446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16447 {
16448 return qe_invalid;
16449 }
16450
16451 30759936 }
16452 }
16453
16454
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16455 {
16456
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16457 {
16458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16459 {
16460 return qe_invalid;
16461 }
16462 30759936 }
16463
16464
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16465 {
16466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16467 {
16468 return qe_invalid;
16469 }
16470 30759936 }
16471 240312 }
16472
16473
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16474 {
16475 if(!p_getc(&padding,f))
16476 {
16477 return qe_invalid;
16478 }
16479 }
16480
16481 247176 const int32_t _mapsSize = (temp_map->tileWidth*temp_map->tileHeight);
16482
16483
2/2
✓ Branch 0 taken 43502976 times.
✓ Branch 1 taken 247176 times.
43750152 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16484 {
16485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43502976 times.
43502976 if(!p_igetw(&(temp_mapscr->data[k]),f))
16486 {
16487 return qe_invalid;
16488 }
16489 43502976 }
16490
16491
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16492 {
16493 if(!p_getc(&padding,f))
16494 {
16495 return qe_invalid;
16496 }
16497
16498 if(!p_getc(&padding,f))
16499 {
16500 return qe_invalid;
16501 }
16502 }
16503
16504
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16505 {
16506
2/2
✓ Branch 0 taken 42294912 times.
✓ Branch 1 taken 240312 times.
42535224 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16507 {
16508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
42294912 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16509 {
16510 return qe_invalid;
16511 }
16512
16513
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42294912 if((Header->zelda_version == 0x192)&&(Header->build<24))
16514 {
16515 if(!p_getc(&tempbyte,f))
16516 {
16517 return qe_invalid;
16518 }
16519
16520 if(!p_getc(&tempbyte,f))
16521 {
16522 return qe_invalid;
16523 }
16524
16525 if(!p_getc(&tempbyte,f))
16526 {
16527 return qe_invalid;
16528 }
16529 }
16530 42294912 }
16531 240312 }
16532
16533
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16534 {
16535
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 42294912 times.
42535224 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16536 {
16537
16538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
42294912 if(!p_getc(&(temp_mapscr->cset[k]),f))
16539 {
16540 return qe_invalid;
16541 }
16542 42294912 }
16543 240312 }
16544
16545
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16546 {
16547 6864 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16548 6864 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16549 6864 }
16550
16551
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16552 {
16553 6864 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16554 6864 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16555 6864 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16556 6864 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16557 6864 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16558 6864 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16559 6864 }
16560
16561
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16562 {
16563
2/2
✓ Branch 0 taken 1208064 times.
✓ Branch 1 taken 6864 times.
1214928 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16564 {
16565
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version == 0x192)&&(Header->build>149))
16566 {
16567 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16568 {
16569 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16570 }
16571 }
16572 else
16573 {
16574
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version < 0x192)||
16575 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16576 {
16577 1208064 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16578 1208064 }
16579
16580 1208064 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16581 }
16582
16583 1208064 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16584 1208064 }
16585 6864 }
16586
16587 /*if(version>12)
16588 {
16589 if(!p_getc(&(temp_mapscr->scrWidth),f))
16590 {
16591 return qe_invalid;
16592 }
16593 if(!p_getc(&(temp_mapscr->scrHeight),f))
16594 {
16595 return qe_invalid;
16596 }
16597 }*/
16598
16599
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>4)
16600 {
16601
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16602 {
16603 return qe_invalid;
16604 }
16605 153408 }
16606 else
16607 {
16608 93768 temp_mapscr->screen_midi = -1;
16609 }
16610
16611
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>=17)
16612 {
16613
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->lens_layer),f))
16614 {
16615 return qe_invalid;
16616 }
16617 153408 }
16618 else
16619 {
16620 93768 temp_mapscr->lens_layer = llNORMAL;
16621 }
16622
16623
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version>6)
16624 {
16625 dword bits;
16626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_igetl(&bits,f))
16627 {
16628 return qe_invalid;
16629 }
16630
16631 int32_t m;
16632 float tempfloat;
16633 word tempw;
16634 153408 temp_mapscr->ffcCountMarkDirty();
16635
16636
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 4909056 times.
5062464 for(m=0; m<32; m++)
16637 {
16638 4909056 ffcdata& tempffc = temp_mapscr->ffcs[m];
16639 4909056 tempffc.clear();
16640
2/2
✓ Branch 0 taken 4886067 times.
✓ Branch 1 taken 22989 times.
4909056 if((bits>>m)&1)
16641 {
16642
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(!p_igetw(&tempw,f))
16643 {
16644 return qe_invalid;
16645 }
16646 22989 tempffc.setData(tempw);
16647
16648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempffc.cset),f))
16649 {
16650 return qe_invalid;
16651 }
16652
16653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetw(&(tempffc.delay),f))
16654 {
16655 return qe_invalid;
16656 }
16657
16658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(version < 9)
16659 {
16660 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16661 {
16662 return qe_invalid;
16663 }
16664
16665 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16666
16667 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16668 {
16669 return qe_invalid;
16670 }
16671
16672 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16673
16674 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16675 {
16676 return qe_invalid;
16677 }
16678
16679 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16680
16681 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16682 {
16683 return qe_invalid;
16684 }
16685
16686 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16687
16688 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16689 {
16690 return qe_invalid;
16691 }
16692
16693 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16694
16695 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16696 {
16697 return qe_invalid;
16698 }
16699
16700 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16701 }
16702 else
16703 {
16704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.x),f))
16705 {
16706 return qe_invalid;
16707 }
16708
16709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.y),f))
16710 {
16711 return qe_invalid;
16712 }
16713
16714
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(!p_igetzf(&(tempffc.vx),f))
16715 {
16716 return qe_invalid;
16717 }
16718
16719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.vy),f))
16720 {
16721 return qe_invalid;
16722 }
16723
16724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.ax),f))
16725 {
16726 return qe_invalid;
16727 }
16728
16729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.ay),f))
16730 {
16731 return qe_invalid;
16732 }
16733 }
16734
16735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempffc.link),f))
16736 {
16737 return qe_invalid;
16738 }
16739
16740
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>7)
16741 {
16742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&tempbyte,f))
16743 {
16744 return qe_invalid;
16745 }
16746
16747 22989 tempffc.hit_width = (tempbyte&0x3F)+1;
16748 22989 tempffc.txsz = (tempbyte>>6)+1;
16749
16750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&tempbyte,f))
16751 {
16752 return qe_invalid;
16753 }
16754
16755 22989 tempffc.hit_height = (tempbyte&0x3F)+1;
16756 22989 tempffc.tysz = (tempbyte>>6)+1;
16757
16758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.flags),f))
16759 {
16760 return qe_invalid;
16761 }
16762 22989 }
16763 else
16764 {
16765 tempffc.hit_width=16;
16766 tempffc.hit_height=16;
16767 tempffc.txsz=1;
16768 tempffc.tysz=1;
16769 tempffc.flags=0;
16770 }
16771
16772 22989 tempffc.updateSolid();
16773
16774
16775
4/6
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20969 times.
✓ Branch 3 taken 2020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20969 times.
22989 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16776 {
16777 tempffc.flags|=ffIGNOREHOLDUP;
16778 }
16779
16780
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>9)
16781 {
16782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetw(&(tempffc.script),f))
16783 {
16784 return qe_invalid;
16785 }
16786 22989 }
16787 else
16788 {
16789 tempffc.script=0;
16790 }
16791
16792
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>10)
16793 {
16794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[0]),f))
16795 {
16796 return qe_invalid;
16797 }
16798
16799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[1]),f))
16800 {
16801 return qe_invalid;
16802 }
16803
16804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[2]),f))
16805 {
16806 return qe_invalid;
16807 }
16808
16809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[3]),f))
16810 {
16811 return qe_invalid;
16812 }
16813
16814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[4]),f))
16815 {
16816 return qe_invalid;
16817 }
16818
16819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[5]),f))
16820 {
16821 return qe_invalid;
16822 }
16823
16824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[6]),f))
16825 {
16826 return qe_invalid;
16827 }
16828
16829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[7]),f))
16830 {
16831 return qe_invalid;
16832 }
16833
16834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempbyte),f))
16835 {
16836 return qe_invalid;
16837 }
16838
16839 22989 tempffc.inita[0]=tempbyte*10000;
16840
16841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempbyte),f))
16842 {
16843 return qe_invalid;
16844 }
16845
16846 22989 tempffc.inita[1]=tempbyte*10000;
16847 22989 }
16848 else
16849 {
16850 tempffc.inita[0] = 10000;
16851 tempffc.inita[1] = 10000;
16852 }
16853
16854
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version <= 11)
16855 {
16856 fixffcs=true;
16857 }
16858 22989 }
16859 4909056 }
16860
2/2
✓ Branch 0 taken 14727168 times.
✓ Branch 1 taken 153408 times.
14880576 for(m = 32; m < MAXFFCS; ++m)
16861 {
16862 14727168 temp_mapscr->ffcs[m].clear();
16863 14727168 }
16864 153408 }
16865
16866 //add in the new whistle flags
16867
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version<13)
16868 {
16869
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 93749 times.
93768 if(temp_mapscr->flags & fWHISTLE)
16870 {
16871 19 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16872 19 }
16873 93768 }
16874
16875 //2.55 starts here
16876
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 19 && Header->zelda_version > 0x253 )
16877 {
16878
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16879 {
16880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16881 {
16882 return qe_invalid;
16883 }
16884 137360 }
16885
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16886 {
16887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16888 {
16889 return qe_invalid;
16890 }
16891 137360 }
16892
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16893 {
16894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16895 {
16896 return qe_invalid;
16897 }
16898 137360 }
16899
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 137360 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16900 {
16901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16902 {
16903 return qe_invalid;
16904 }
16905 137360 }
16906 13736 }
16907
3/4
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 233440 times.
247176 if ( version < 19 && Header->zelda_version > 0x253 )
16908 {
16909 for ( int32_t q = 0; q < 10; q++ )
16910 {
16911 temp_mapscr->npcstrings[q] = 0;
16912 temp_mapscr->new_items[q] = 0;
16913 temp_mapscr->new_item_x[q] = 0;
16914 temp_mapscr->new_item_y[q] = 0;
16915 }
16916 }
16917
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 20 && Header->zelda_version > 0x253 )
16918 {
16919
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_igetw(&(temp_mapscr->script),f))
16920 {
16921 return qe_invalid;
16922 }
16923
2/2
✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 13736 times.
123624 for ( int32_t q = 0; q < 8; q++)
16924 {
16925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109888 times.
109888 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16926 {
16927 return qe_invalid;
16928 }
16929 109888 }
16930 13736 }
16931
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
247176 if ( version < 20 )
16932 {
16933 233440 temp_mapscr->script = 0;
16934
2/2
✓ Branch 0 taken 1867520 times.
✓ Branch 1 taken 233440 times.
2100960 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16935 233440 }
16936
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 21 && Header->zelda_version > 0x253 )
16937 {
16938
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->preloadscript),f))
16939 {
16940 return qe_invalid;
16941 }
16942 13736 }
16943
2/2
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
247176 if ( version < 21 )
16944 {
16945 233440 temp_mapscr->preloadscript = 0;
16946 233440 }
16947 //all builds with version > 20 need this. -Z
16948
16949
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16950 {
16951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13736 times.
13736 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16952 {
16953 return qe_invalid;
16954 }
16955
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16956 {
16957 return qe_invalid;
16958 }
16959 13736 }
16960
2/2
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
247176 if ( version < 22 )
16961 {
16962 233440 temp_mapscr->hidelayers = 0;
16963 233440 temp_mapscr->hidescriptlayers = 0;
16964 233440 }
16965
16966 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16967 //May be any version before 2.11. -Z
16968 /* --not the roar, the HIT SFX
16969 if ( Header->zelda_version <= 0x210 )
16970 {
16971 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16972 {
16973 temp_mapscr->bosssfx = WAV_ROAR;
16974 }
16975 }
16976 */
16977
16978 247176 return 0;
16979 247176 }
16980 262000 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version, int scrind)
16981 {
16982
2/2
✓ Branch 0 taken 247176 times.
✓ Branch 1 taken 14824 times.
262000 if(version < 23)
16983 {
16984 247176 auto ret = readmapscreen_old(f,Header,temp_mapscr,temp_map,version);
16985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(ret) return ret;
16986 247176 }
16987 else
16988 {
16989
1/2
✓ Branch 0 taken 14824 times.
✗ Branch 1 not taken.
14824 if(!p_getc(&(temp_mapscr->valid),f))
16990 return qe_invalid;
16991
2/2
✓ Branch 0 taken 9071 times.
✓ Branch 1 taken 5753 times.
14824 if(!(temp_mapscr->valid & mVALID))
16992 {
16993 9071 int map = scrind/MAPSCRS;
16994 9071 int scr = scrind%MAPSCRS;
16995
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9071 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9071 if(version > 25 && scrind > -1 && (map*6+5) < map_autolayers.size())
16996 {
16997 //Empty screen, apply autolayers
16998 for(int q = 0; q < 6; ++q)
16999 {
17000 auto layermap = map_autolayers[map*6+q];
17001 temp_mapscr->layermap[q] = layermap;
17002 if(layermap)
17003 temp_mapscr->layerscreen[q] = scr;
17004 }
17005 }
17006 9071 return 0;
17007 }
17008 uint32_t scr_has_flags;
17009
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(!p_igetl(&scr_has_flags,f))
17010 return qe_invalid;
17011
17012
2/2
✓ Branch 0 taken 5693 times.
✓ Branch 1 taken 60 times.
5753 if(scr_has_flags & SCRHAS_ROOMDATA)
17013 {
17014
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&(temp_mapscr->guy),f))
17015 return qe_invalid;
17016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(version > 26)
17017 {
17018 if(!p_igetl(&(temp_mapscr->guytile),f))
17019 return qe_invalid;
17020 if(!p_getc(&(temp_mapscr->guycs),f))
17021 return qe_invalid;
17022 if(!p_igetw(&(temp_mapscr->roomflags),f))
17023 return qe_invalid;
17024 }
17025 else
17026 {
17027 60 temp_mapscr->guytile = -1; //signal to use default guy values
17028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
17029
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
60 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
17030 }
17031
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_igetw(&(temp_mapscr->str),f))
17032 return qe_invalid;
17033
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&(temp_mapscr->room),f))
17034 return qe_invalid;
17035
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_igetw(&(temp_mapscr->catchall),f))
17036 return qe_invalid;
17037 60 }
17038
2/2
✓ Branch 0 taken 5642 times.
✓ Branch 1 taken 111 times.
5753 if(scr_has_flags & SCRHAS_ITEM)
17039 {
17040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(!p_getc(&(temp_mapscr->item),f))
17041 return qe_invalid;
17042
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_getc(&(temp_mapscr->hasitem),f))
17043 return qe_invalid;
17044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(!p_getc(&(temp_mapscr->itemx),f))
17045 return qe_invalid;
17046
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_getc(&(temp_mapscr->itemy),f))
17047 return qe_invalid;
17048 111 }
17049
2/2
✓ Branch 0 taken 5415 times.
✓ Branch 1 taken 338 times.
5753 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
17050 {
17051
1/2
✓ Branch 0 taken 338 times.
✗ Branch 1 not taken.
338 if(!p_igetw(&temp_mapscr->warpreturnc,f))
17052 return qe_invalid;
17053 338 }
17054
2/2
✓ Branch 0 taken 5528 times.
✓ Branch 1 taken 225 times.
5753 if(scr_has_flags & SCRHAS_TWARP)
17055 {
17056
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 225 times.
1125 for(int32_t i=0; i<4; i++)
17057 {
17058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
900 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
17059 return qe_invalid;
17060 900 }
17061
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 225 times.
1125 for(int32_t i=0; i<4; i++)
17062 {
17063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
900 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
17064 return qe_invalid;
17065 900 }
17066
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 225 times.
1125 for(int32_t i=0; i<4; i++)
17067 {
17068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
900 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
17069 return qe_invalid;
17070 900 }
17071
1/2
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
225 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
17072 return qe_invalid;
17073 225 }
17074
2/2
✓ Branch 0 taken 5614 times.
✓ Branch 1 taken 139 times.
5753 if(scr_has_flags & SCRHAS_SWARP)
17075 {
17076
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17077 {
17078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
17079 return qe_invalid;
17080 556 }
17081
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17082 {
17083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
17084 return qe_invalid;
17085 556 }
17086
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17087 {
17088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
17089 return qe_invalid;
17090 556 }
17091
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
17092 return qe_invalid;
17093
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
17094 return qe_invalid;
17095 139 }
17096
2/2
✓ Branch 0 taken 5411 times.
✓ Branch 1 taken 342 times.
5753 if(scr_has_flags & SCRHAS_WARPRET)
17097 {
17098
2/2
✓ Branch 0 taken 1368 times.
✓ Branch 1 taken 342 times.
1710 for(int32_t i=0; i<4; i++)
17099 {
17100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1368 times.
1368 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
17101 return qe_invalid;
17102 1368 }
17103
2/2
✓ Branch 0 taken 1368 times.
✓ Branch 1 taken 342 times.
1710 for(int32_t i=0; i<4; i++)
17104 {
17105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1368 times.
1368 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
17106 return qe_invalid;
17107 1368 }
17108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 342 times.
342 if(!p_getc(&(temp_mapscr->warparrivalx),f))
17109 return qe_invalid;
17110
1/2
✓ Branch 0 taken 342 times.
✗ Branch 1 not taken.
342 if(!p_getc(&(temp_mapscr->warparrivaly),f))
17111 return qe_invalid;
17112 342 }
17113
2/2
✓ Branch 0 taken 4637 times.
✓ Branch 1 taken 1116 times.
5753 if(scr_has_flags & SCRHAS_LAYERS)
17114 {
17115
2/2
✓ Branch 0 taken 6696 times.
✓ Branch 1 taken 1116 times.
7812 for(int32_t k=0; k<6; k++)
17116 {
17117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6696 times.
6696 if(!p_getc(&(temp_mapscr->layermap[k]),f))
17118 return qe_invalid;
17119 6696 }
17120
2/2
✓ Branch 0 taken 6696 times.
✓ Branch 1 taken 1116 times.
7812 for(int32_t k=0; k<6; k++)
17121 {
17122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6696 times.
6696 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
17123 return qe_invalid;
17124 6696 }
17125
2/2
✓ Branch 0 taken 6696 times.
✓ Branch 1 taken 1116 times.
7812 for(int32_t k=0; k<6; k++)
17126 {
17127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6696 times.
6696 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
17128 return qe_invalid;
17129 6696 }
17130
1/2
✓ Branch 0 taken 1116 times.
✗ Branch 1 not taken.
1116 if(!p_getc(&(temp_mapscr->hidelayers),f))
17131 return qe_invalid;
17132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1116 times.
1116 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
17133 return qe_invalid;
17134 1116 }
17135
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(scr_has_flags & SCRHAS_MAZE)
17136 {
17137 for(int32_t k=0; k<4; k++)
17138 {
17139 if(!p_getc(&(temp_mapscr->path[k]),f))
17140 return qe_invalid;
17141 }
17142 if(!p_getc(&(temp_mapscr->exitdir),f))
17143 return qe_invalid;
17144 }
17145
2/2
✓ Branch 0 taken 5620 times.
✓ Branch 1 taken 133 times.
5753 if(scr_has_flags & SCRHAS_D_S_U)
17146 {
17147
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
17148 return qe_invalid;
17149
2/2
✓ Branch 0 taken 532 times.
✓ Branch 1 taken 133 times.
665 for(int32_t k=0; k<4; k++)
17150 {
17151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 if(!p_getc(&(temp_mapscr->door[k]),f))
17152 return qe_invalid;
17153 532 }
17154
17155
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_getc(&(temp_mapscr->stairx),f))
17156 return qe_invalid;
17157
17158
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_getc(&(temp_mapscr->stairy),f))
17159 return qe_invalid;
17160
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_igetw(&(temp_mapscr->undercombo),f))
17161 return qe_invalid;
17162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
133 if(!p_getc(&(temp_mapscr->undercset),f))
17163 return qe_invalid;
17164 133 }
17165
2/2
✓ Branch 0 taken 5348 times.
✓ Branch 1 taken 405 times.
5753 if(scr_has_flags & SCRHAS_FLAGS)
17166 {
17167
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->flags),f))
17168 return qe_invalid;
17169
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->flags2),f))
17170 return qe_invalid;
17171
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->flags3),f))
17172 return qe_invalid;
17173
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->flags4),f))
17174 return qe_invalid;
17175
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->flags5),f))
17176 return qe_invalid;
17177
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->flags6),f))
17178 return qe_invalid;
17179
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->flags7),f))
17180 return qe_invalid;
17181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 405 times.
405 if(!p_getc(&(temp_mapscr->flags8),f))
17182 return qe_invalid;
17183
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->flags9),f))
17184 return qe_invalid;
17185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 405 times.
405 if(!p_getc(&(temp_mapscr->flags10),f))
17186 return qe_invalid;
17187
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->enemyflags),f))
17188 return qe_invalid;
17189 405 }
17190
2/2
✓ Branch 0 taken 5386 times.
✓ Branch 1 taken 367 times.
5753 if(scr_has_flags & SCRHAS_ENEMY)
17191 {
17192
2/2
✓ Branch 0 taken 3670 times.
✓ Branch 1 taken 367 times.
4037 for(int32_t k=0; k<10; k++)
17193 {
17194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3670 times.
3670 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
17195 return qe_invalid;
17196
1/2
✓ Branch 0 taken 3670 times.
✗ Branch 1 not taken.
3670 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17197 temp_mapscr->enemy[k] = 0;
17198 3670 }
17199
1/2
✓ Branch 0 taken 367 times.
✗ Branch 1 not taken.
367 if(!p_getc(&(temp_mapscr->pattern),f))
17200 return qe_invalid;
17201 367 }
17202
2/2
✓ Branch 0 taken 5720 times.
✓ Branch 1 taken 33 times.
5753 if(scr_has_flags & SCRHAS_CARRY)
17203 {
17204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(!p_igetw(&(temp_mapscr->noreset),f))
17205 return qe_invalid;
17206
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&(temp_mapscr->nocarry),f))
17207 return qe_invalid;
17208
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextmap),f))
17209 return qe_invalid;
17210
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextscr),f))
17211 return qe_invalid;
17212 33 }
17213
2/2
✓ Branch 0 taken 5722 times.
✓ Branch 1 taken 31 times.
5753 if(scr_has_flags & SCRHAS_SCRIPT)
17214 {
17215
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&(temp_mapscr->script),f))
17216 return qe_invalid;
17217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(!p_getc(&(temp_mapscr->preloadscript),f))
17218 return qe_invalid;
17219
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 31 times.
279 for ( int32_t q = 0; q < 8; q++ )
17220 {
17221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
248 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
17222 return qe_invalid;
17223 248 }
17224 31 }
17225
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(scr_has_flags & SCRHAS_UNUSED)
17226 {
17227 for ( int32_t q = 0; q < 10; q++ )
17228 {
17229 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
17230 return qe_invalid;
17231 }
17232 for ( int32_t q = 0; q < 10; q++ )
17233 {
17234 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
17235 return qe_invalid;
17236 }
17237 for ( int32_t q = 0; q < 10; q++ )
17238 {
17239 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
17240 return qe_invalid;
17241 }
17242 for ( int32_t q = 0; q < 10; q++ )
17243 {
17244 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
17245 return qe_invalid;
17246 }
17247 }
17248
2/2
✓ Branch 0 taken 5356 times.
✓ Branch 1 taken 397 times.
5753 if(scr_has_flags & SCRHAS_SECRETS)
17249 {
17250
2/2
✓ Branch 0 taken 50816 times.
✓ Branch 1 taken 397 times.
51213 for(int32_t k=0; k<128; k++)
17251 {
17252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50816 times.
50816 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
17253 return qe_invalid;
17254 50816 }
17255
2/2
✓ Branch 0 taken 50816 times.
✓ Branch 1 taken 397 times.
51213 for(int32_t k=0; k<128; k++)
17256 {
17257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50816 times.
50816 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
17258 return qe_invalid;
17259 50816 }
17260
2/2
✓ Branch 0 taken 50816 times.
✓ Branch 1 taken 397 times.
51213 for(int32_t k=0; k<128; k++)
17261 {
17262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50816 times.
50816 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
17263 return qe_invalid;
17264 50816 }
17265 397 }
17266
2/2
✓ Branch 0 taken 2945 times.
✓ Branch 1 taken 2808 times.
5753 if(scr_has_flags & SCRHAS_COMBOFLAG)
17267 {
17268
2/2
✓ Branch 0 taken 494208 times.
✓ Branch 1 taken 2808 times.
497016 for(int32_t k=0; k<176; ++k)
17269 {
17270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 494208 times.
494208 if(!p_igetw(&(temp_mapscr->data[k]),f))
17271 return qe_invalid;
17272 494208 }
17273
2/2
✓ Branch 0 taken 494208 times.
✓ Branch 1 taken 2808 times.
497016 for(int32_t k=0; k<176; ++k)
17274 {
17275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 494208 times.
494208 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17276 return qe_invalid;
17277 494208 }
17278
2/2
✓ Branch 0 taken 494208 times.
✓ Branch 1 taken 2808 times.
497016 for(int32_t k=0; k<176; ++k)
17279 {
17280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 494208 times.
494208 if(!p_getc(&(temp_mapscr->cset[k]),f))
17281 return qe_invalid;
17282 494208 }
17283 2808 }
17284
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(scr_has_flags & SCRHAS_MISC)
17285 {
17286
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(!p_igetw(&(temp_mapscr->color),f))
17287 return qe_invalid;
17288
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(!p_getc(&(temp_mapscr->csensitive),f))
17289 return qe_invalid;
17290
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(!p_getc(&(temp_mapscr->oceansfx),f))
17291 return qe_invalid;
17292
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(!p_getc(&(temp_mapscr->bosssfx),f))
17293 return qe_invalid;
17294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5753 times.
5753 if(!p_getc(&(temp_mapscr->secretsfx),f))
17295 return qe_invalid;
17296
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17297 return qe_invalid;
17298
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17299 return qe_invalid;
17300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5753 times.
5753 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17301 return qe_invalid;
17302
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(!p_getc(&(temp_mapscr->lens_layer),f))
17303 return qe_invalid;
17304 5753 }
17305 else
17306 {
17307 temp_mapscr->screen_midi = -1;
17308 temp_mapscr->csensitive = 1;
17309 }
17310 //FFC
17311 5753 bool old_ff = version < 25;
17312 5753 dword bits = 0;
17313 5753 word numffc = 32;
17314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5753 times.
5753 if(old_ff)
17315 {
17316 if(!p_igetl(&bits,f))
17317 return qe_invalid;
17318 }
17319 else
17320 {
17321
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(!p_igetw(&numffc,f))
17322 return qe_invalid;
17323 }
17324 byte tempbyte;
17325 word tempw;
17326
4/6
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 5726 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
✓ Branch 4 taken 27 times.
✗ Branch 5 not taken.
5753 static ffcdata nil_ffc;
17327 5753 temp_mapscr->ffcCountMarkDirty();
17328
2/2
✓ Branch 0 taken 5753 times.
✓ Branch 1 taken 7870 times.
13623 for(word m = 0; m < numffc; ++m)
17329 {
17330
1/2
✓ Branch 0 taken 7870 times.
✗ Branch 1 not taken.
7870 ffcdata& tempffc = (m < MAXFFCS)
17331 7870 ? temp_mapscr->ffcs[m]
17332 : nil_ffc; //sanity
17333 7870 tempffc.clear();
17334
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7870 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7870 if(old_ff && !(bits & (1<<m))) continue;
17335
17336
1/2
✓ Branch 0 taken 7870 times.
✗ Branch 1 not taken.
7870 if(!p_igetw(&tempw,f))
17337 return qe_invalid;
17338
3/4
✓ Branch 0 taken 7870 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1372 times.
✓ Branch 3 taken 6498 times.
7870 if(!old_ff && !tempw) //empty ffc, nothing more to load
17339 6498 continue;
17340 1372 tempffc.setData(tempw);
17341
17342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_getc(&(tempffc.cset),f))
17343 return qe_invalid;
17344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_igetw(&(tempffc.delay),f))
17345 return qe_invalid;
17346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_igetzf(&(tempffc.x),f))
17347 return qe_invalid;
17348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_igetzf(&(tempffc.y),f))
17349 return qe_invalid;
17350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_igetzf(&(tempffc.vx),f))
17351 return qe_invalid;
17352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_igetzf(&(tempffc.vy),f))
17353 return qe_invalid;
17354
1/2
✓ Branch 0 taken 1372 times.
✗ Branch 1 not taken.
1372 if(!p_igetzf(&(tempffc.ax),f))
17355 return qe_invalid;
17356
1/2
✓ Branch 0 taken 1372 times.
✗ Branch 1 not taken.
1372 if(!p_igetzf(&(tempffc.ay),f))
17357 return qe_invalid;
17358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_getc(&(tempffc.link),f))
17359 return qe_invalid;
17360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(version < 24)
17361 {
17362 if(!p_getc(&tempbyte,f))
17363 return qe_invalid;
17364 tempffc.hit_width = (tempbyte&0x3F)+1;
17365 tempffc.txsz = (tempbyte>>6)+1;
17366 if(!p_getc(&tempbyte,f))
17367 return qe_invalid;
17368 tempffc.hit_height = (tempbyte&0x3F)+1;
17369 tempffc.tysz = (tempbyte>>6)+1;
17370 }
17371 else
17372 {
17373
1/2
✓ Branch 0 taken 1372 times.
✗ Branch 1 not taken.
1372 if(!p_igetl(&(tempffc.hit_width),f))
17374 return qe_invalid;
17375
1/2
✓ Branch 0 taken 1372 times.
✗ Branch 1 not taken.
1372 if(!p_igetl(&(tempffc.hit_height),f))
17376 return qe_invalid;
17377
1/2
✓ Branch 0 taken 1372 times.
✗ Branch 1 not taken.
1372 if(!p_getc(&(tempffc.txsz),f))
17378 return qe_invalid;
17379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_getc(&(tempffc.tysz),f))
17380 return qe_invalid;
17381 }
17382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_igetl(&(tempffc.flags),f))
17383 return qe_invalid;
17384 1372 tempffc.updateSolid();
17385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_igetw(&(tempffc.script),f))
17386 return qe_invalid;
17387
2/2
✓ Branch 0 taken 10976 times.
✓ Branch 1 taken 1372 times.
12348 for(auto q = 0; q < 8; ++q)
17388 {
17389
1/2
✓ Branch 0 taken 10976 times.
✗ Branch 1 not taken.
10976 if(!p_igetl(&(tempffc.initd[q]),f))
17390 return qe_invalid;
17391 10976 }
17392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_getc(&(tempbyte),f))
17393 return qe_invalid;
17394 1372 tempffc.inita[0]=tempbyte*10000;
17395
17396
1/2
✓ Branch 0 taken 1372 times.
✗ Branch 1 not taken.
1372 if(!p_getc(&(tempbyte),f))
17397 return qe_invalid;
17398 1372 tempffc.inita[1]=tempbyte*10000;
17399 1372 }
17400
2/2
✓ Branch 0 taken 728514 times.
✓ Branch 1 taken 5753 times.
734267 for(word m = numffc; m < MAXFFCS; ++m)
17401 {
17402 728514 temp_mapscr->ffcs[m].clear();
17403 728514 }
17404 //END FFC
17405 }
17406 252929 return 0;
17407 262000 }
17408
17409
17410 123 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17411 {
17412 123 int32_t scr=0;
17413
17414 123 word version=0;
17415 dword dummy;
17416 int32_t screens_to_read;
17417
17418 123 mapscr temp_mapscr;
17419 zcmap temp_map;
17420 word temp_map_count;
17421 dword section_size;
17422
17423
3/6
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
123 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17424 {
17425 4 screens_to_read=MAPSCRS192b136;
17426 4 }
17427 else
17428 {
17429 119 screens_to_read=MAPSCRS;
17430 }
17431
17432
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
123 if(Header->zelda_version > 0x192)
17433 {
17434 //section version info
17435
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&version,f))
17436 {
17437 return qe_invalid;
17438 }
17439
17440 119 FFCore.quest_format[vMaps] = version;
17441
17442 //al_trace("Maps version %d\n", version);
17443
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&dummy,f))
17444 {
17445 return qe_invalid;
17446 }
17447
17448 //section size
17449
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetl(&section_size,f))
17450 {
17451 return qe_invalid;
17452 }
17453
17454 //finally... section data
17455
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&temp_map_count,f))
17456 {
17457 return 5;
17458 }
17459 119 }
17460 else
17461 {
17462 4 temp_map_count=map_count;
17463 }
17464
17465
2/4
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 123 times.
123 if (!(temp_map_count >= 0 && temp_map_count <= MAXMAPS2))
17466 {
17467 return qe_invalid;
17468 }
17469
17470 123 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17471 123 TheMaps.resize(_mapsSize);
17472 123 map_autolayers.clear();
17473 123 map_autolayers.resize(temp_map_count*6);
17474
17475
2/2
✓ Branch 0 taken 263160 times.
✓ Branch 1 taken 123 times.
263283 for(int32_t i(0); i<_mapsSize; i++)
17476 263160 TheMaps[i].zero_memory();
17477
17478 123 memset(ZCMaps, 0, sizeof(zcmap)*MAXMAPS2);
17479
17480 123 temp_mapscr.zero_memory();
17481
17482 { //Is this stuff even needed anymore? Is it used at all? -Em
17483 123 memset(&temp_map, 0, sizeof(zcmap));
17484 123 temp_map.scrResWidth = 256;
17485 123 temp_map.scrResHeight = 224;
17486 123 temp_map.tileWidth = 16;
17487 123 temp_map.tileHeight = 11;
17488 123 temp_map.viewWidth = 256;
17489 123 temp_map.viewHeight = 176;
17490 123 temp_map.viewX = 0;
17491 123 temp_map.viewY = 64;
17492 123 temp_map.subaWidth = 256;
17493 123 temp_map.subaHeight = 168;
17494 123 temp_map.subaTrans = false;
17495 123 temp_map.subpWidth = 256;
17496 123 temp_map.subpHeight = 56;
17497 123 temp_map.subpTrans = false;
17498 }
17499
4/4
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 1935 times.
✓ Branch 2 taken 1935 times.
✓ Branch 3 taken 123 times.
2058 for(int32_t i=0; i<temp_map_count && i<MAXMAPS2; i++)
17500 {
17501 //!TODO Trim fully
17502 1935 memcpy(&ZCMaps[i], &temp_map, sizeof(zcmap));
17503
17504 1935 byte valid=1;
17505
2/2
✓ Branch 0 taken 1819 times.
✓ Branch 1 taken 116 times.
1935 if(version > 22)
17506 {
17507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&valid,f))
17508 return qe_invalid;
17509 116 }
17510
3/4
✓ Branch 0 taken 1928 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 1928 times.
✗ Branch 3 not taken.
1935 if(valid && version > 25)
17511 {
17512 for(int q = 0; q < 6; ++q)
17513 {
17514 if(!p_igetw(&map_autolayers[i*6+q],f))
17515 return qe_invalid;
17516 }
17517 }
17518
2/2
✓ Branch 0 taken 262952 times.
✓ Branch 1 taken 1935 times.
264887 for(int32_t j=0; j<screens_to_read; j++)
17519 {
17520 262952 scr=i*MAPSCRS+j;
17521 262952 clear_screen(&temp_mapscr);
17522
2/2
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 262000 times.
262952 if(valid)
17523 262000 readmapscreen(f, Header, &temp_mapscr, &temp_map, version, scr);
17524
17525 262952 TheMaps[scr] = temp_mapscr;
17526 262952 }
17527
17528
3/6
✓ Branch 0 taken 1883 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1883 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1935 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17529 {
17530 52 int32_t index = (i*MAPSCRS+132);
17531
17532 52 TheMaps[index]=TheMaps[index-1];
17533
17534 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17535 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17536 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17537
17538
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 52 times.
208 for(int32_t j=133; j<MAPSCRS; j++)
17539 {
17540 156 scr=i*MAPSCRS+j;
17541
17542 156 TheMaps[scr].zero_memory();
17543 156 TheMaps[scr].valid = mVERSION;
17544 156 TheMaps[scr].screen_midi = -1;
17545 156 TheMaps[scr].csensitive = 1;
17546 156 }
17547 52 }
17548
17549
3/6
✓ Branch 0 taken 1883 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1883 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1935 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17550 {
17551
2/2
✓ Branch 0 taken 7072 times.
✓ Branch 1 taken 52 times.
7124 for(int32_t j=0; j<MAPSCRS; j++)
17552 {
17553 7072 scr=i*MAPSCRS+j;
17554 7072 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17555
17556
2/2
✓ Branch 0 taken 905216 times.
✓ Branch 1 taken 7072 times.
912288 for(int32_t k=0; k<128; k++)
17557 {
17558 905216 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17559 905216 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17560 905216 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17561 905216 }
17562 7072 }
17563 52 }
17564 1935 }
17565 123 map_count = temp_map_count;
17566 123 clear_screen(&temp_mapscr);
17567 123 return 0;
17568 123 }
17569
17570
17571 1063693 void update_combo(newcombo& cmb, word section_version)
17572 {
17573
2/2
✓ Branch 0 taken 122976 times.
✓ Branch 1 taken 940717 times.
1063693 if(section_version < 40)
17574 {
17575
3/3
✓ Branch 0 taken 1389 times.
✓ Branch 1 taken 14209 times.
✓ Branch 2 taken 925119 times.
940717 switch(cmb.type)
17576 {
17577 case cWATER: case cSHALLOWWATER:
17578 14209 cmb.attribytes[6] = iwRipples;
17579 14209 break;
17580 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17581 1389 cmb.attribytes[6] = iwTallGrass;
17582 1389 break;
17583 }
17584 940717 }
17585 1063693 }
17586 95 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17587 {
17588 95 reset_combo_animations();
17589 95 reset_combo_animations2();
17590
17591 95 init_combo_classes();
17592
17593 // combos
17594 95 word combos_used=0;
17595 int32_t dummy;
17596 byte padding;
17597 95 newcombo temp_combo;
17598 //word section_cversion=0;
17599
17600
2/2
✓ Branch 0 taken 6201600 times.
✓ Branch 1 taken 95 times.
6201695 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17601
1/2
✓ Branch 0 taken 6201600 times.
✗ Branch 1 not taken.
6201600 combobuf[q].clear();
17602
17603 // if(version > 0x192)
17604 // {
17605 // //section version info
17606 // if(!p_igetw(&section_version,f))
17607 // {
17608 // return qe_invalid;
17609 // }
17610
17611 // FFCore.quest_format[vCombos] = section_version;
17612
17613 // //al_trace("Combos version %d\n", section_version);
17614 // if(!p_igetw(&section_cversion,f))
17615 // {
17616 // return qe_invalid;
17617 // }
17618
17619 // //section size
17620 // if(!p_igetl(&dummy,f))
17621 // {
17622 // return qe_invalid;
17623 // }
17624 // }
17625
17626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if(version < 0x174)
17627 {
17628 combos_used=1024;
17629 }
17630
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
95 else if(version < 0x191)
17631 {
17632 4 combos_used=2048;
17633 4 }
17634 else
17635 {
17636
2/4
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91 times.
✗ Branch 3 not taken.
91 if(!p_igetw(&combos_used,f))
17637 {
17638 return qe_invalid;
17639 }
17640 }
17641
17642 //finally... section data
17643
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 873209 times.
873304 for(int32_t i=0; i<combos_used; i++)
17644 {
17645
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 temp_combo.clear();
17646
17647
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if ( section_version >= 11 )
17648 {
17649
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.tile,f))
17650 {
17651 return qe_invalid;
17652 }
17653 68884 }
17654 else
17655 {
17656
2/4
✓ Branch 0 taken 804325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 804325 times.
✗ Branch 3 not taken.
804325 if(!p_igetw(&temp_combo.tile,f))
17657 {
17658 return qe_invalid;
17659 }
17660 }
17661 873209 temp_combo.o_tile = temp_combo.tile;
17662
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.flip,f))
17663 {
17664 return qe_invalid;
17665 }
17666
17667
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.walk,f))
17668 {
17669 return qe_invalid;
17670 }
17671
17672
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.type,f))
17673 {
17674 return qe_invalid;
17675 }
17676
17677
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.csets,f))
17678 {
17679 return qe_invalid;
17680 }
17681
17682
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 865017 times.
873209 if(version < 0x193)
17683 {
17684
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f))
17685 return qe_invalid;
17686
17687
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f))
17688 return qe_invalid;
17689
17690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8192 times.
8192 if(version < 0x192)
17691 {
17692
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(version == 0x191)
17693 {
17694 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17695 {
17696 if(!p_getc(&padding,f))
17697 return qe_invalid;
17698 }
17699 }
17700 8192 }
17701 8192 }
17702
2/2
✓ Branch 0 taken 865017 times.
✓ Branch 1 taken 8192 times.
873209 if(version >= 0x192)
17703 {
17704
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.frames,f))
17705 return qe_invalid;
17706
17707
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.speed,f))
17708 return qe_invalid;
17709
17710
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_igetw(&temp_combo.nextcombo,f))
17711 return qe_invalid;
17712
17713
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.nextcset,f))
17714 return qe_invalid;
17715
17716 //Base flag
17717
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=3)
17718
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.flag,f))
17719 return qe_invalid;
17720
17721
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=4)
17722 {
17723
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.skipanim,f))
17724 return qe_invalid;
17725
17726
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_igetw(&temp_combo.nexttimer,f))
17727 return qe_invalid;
17728 399183 }
17729
17730
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=5)
17731
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.skipanimy,f))
17732 return qe_invalid;
17733
17734
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=6)
17735 {
17736
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.animflags,f))
17737 return qe_invalid;
17738
17739
1/2
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
399183 if(section_version == 6)
17740 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17741 399183 }
17742
17743
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=8) //combo Attributes[4] and userflags.
17744 {
17745
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 275536 times.
344420 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17746
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_igetl(&temp_combo.attributes[q],f))
17747 return qe_invalid;
17748
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.usrflags,f))
17749 return qe_invalid;
17750
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(section_version >= 20)
17751
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.genflags,f))
17752 return qe_invalid;
17753 68884 }
17754
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=10) //combo trigger flags
17755 {
17756
2/2
✓ Branch 0 taken 206652 times.
✓ Branch 1 taken 68884 times.
275536 for ( int32_t q = 0; q < 3; q++ )
17757
2/4
✓ Branch 0 taken 206652 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206652 times.
✗ Branch 3 not taken.
206652 if(!p_igetl(&temp_combo.triggerflags[q],f))
17758 return qe_invalid;
17759 68884 }
17760
1/2
✓ Branch 0 taken 796133 times.
✗ Branch 1 not taken.
796133 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17761 {
17762 for ( int32_t q = 0; q < 2; q++ )
17763 if(!p_igetl(&temp_combo.triggerflags[q],f))
17764 return qe_invalid;
17765 }
17766
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version >= 9)
17767
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.triggerlevel,f))
17768 return qe_invalid;
17769
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version >= 22)
17770
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.triggerbtn,f))
17771 return qe_invalid;
17772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 24)
17773 {
17774 if(!p_getc(&temp_combo.triggeritem,f))
17775 return qe_invalid;
17776 if(!p_getc(&temp_combo.trigtimer,f))
17777 return qe_invalid;
17778 }
17779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 25)
17780 if(!p_getc(&temp_combo.trigsfx,f))
17781 return qe_invalid;
17782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 27)
17783 if(!p_igetl(&temp_combo.trigchange,f))
17784 return qe_invalid;
17785
17786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 29)
17787 {
17788 if(!p_igetw(&temp_combo.trigprox,f))
17789 return qe_invalid;
17790 if(!p_getc(&temp_combo.trigctr,f))
17791 return qe_invalid;
17792 if(!p_igetl(&temp_combo.trigctramnt,f))
17793 return qe_invalid;
17794 }
17795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 30)
17796 if(!p_getc(&temp_combo.triglbeam,f))
17797 return qe_invalid;
17798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 31)
17799 {
17800 if(!p_getc(&temp_combo.trigcschange,f))
17801 return qe_invalid;
17802 if(!p_igetw(&temp_combo.spawnitem,f))
17803 return qe_invalid;
17804 if(!p_igetw(&temp_combo.spawnenemy,f))
17805 return qe_invalid;
17806 if(!p_getc(&temp_combo.exstate,f))
17807 return qe_invalid;
17808 if(!p_igetl(&temp_combo.spawnip,f))
17809 return qe_invalid;
17810 if(!p_getc(&temp_combo.trigcopycat,f))
17811 return qe_invalid;
17812 }
17813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 32)
17814 if(!p_getc(&temp_combo.trigcooldown,f))
17815 return qe_invalid;
17816
17817
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=12) //combo label
17818 {
17819 char label[12];
17820 68884 label[11] = '\0';
17821
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 757724 times.
826608 for ( int32_t q = 0; q < 11; q++ )
17822
2/4
✓ Branch 0 taken 757724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757724 times.
✗ Branch 3 not taken.
757724 if(!p_getc(&label[q],f))
17823 return qe_invalid;
17824
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 temp_combo.label = label;
17825 68884 }
17826
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=13) //attribytes[4]
17827
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < 4; q++ )
17828
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f))
17829 68884 return qe_invalid;
17830 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17831 * This fixes a poor implementation of a ->next flag bug thing.
17832 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17833 * there was a version bump a few weeks before a change that broke stuff.
17834 */
17835
3/4
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68884 times.
865017 if (section_version >= 13 && section_version < 21)
17836 {
17837 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17838 }
17839 //combo scripts
17840
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=14)
17841 {
17842
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.script,f))
17843 return qe_invalid;
17844
2/2
✓ Branch 0 taken 137768 times.
✓ Branch 1 taken 68884 times.
206652 for ( int32_t q = 0; q < 2; q++ )
17845
2/4
✓ Branch 0 taken 137768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137768 times.
✗ Branch 3 not taken.
137768 if(!p_igetl(&temp_combo.initd[q],f))
17846 return qe_invalid;
17847 68884 }
17848 //al_trace("Read combo script data\n");
17849
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=15)
17850 {
17851
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17852
2/2
✓ Branch 0 taken 37028 times.
✓ Branch 1 taken 31856 times.
68884 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17853
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17854
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17855 68884 }
17856
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=17) //attribytes[4]
17857 {
17858
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17859
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f))
17860 return qe_invalid;
17861
2/2
✓ Branch 0 taken 551072 times.
✓ Branch 1 taken 68884 times.
619956 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17862
2/4
✓ Branch 0 taken 551072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 551072 times.
✗ Branch 3 not taken.
551072 if(!p_igetw(&temp_combo.attrishorts[q],f))
17863 return qe_invalid;
17864 68884 }
17865
17866
1/2
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
865017 if(version < 0x193)
17867 for(int32_t q=0; q<11; q++)
17868 if(!p_getc(&dummy,f))
17869 return qe_invalid;
17870 865017 }
17871
17872 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17873
3/6
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 474026 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 399183 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
873209 if((version < 0x211)||((version == 0x211)&&(build<7)))
17874 {
17875
3/4
✓ Branch 0 taken 474026 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 465834 times.
✓ Branch 3 taken 8192 times.
474026 if(!get_qr(qr_NEWENEMYTILES))
17876 {
17877
1/5
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
8192 switch(temp_combo.tile)
17878 {
17879 case 130:
17880 temp_combo.tile = 132;
17881 break;
17882
17883 case 131:
17884 temp_combo.tile = 133;
17885 break;
17886
17887 case 132:
17888 temp_combo.tile = 130;
17889 break;
17890
17891 case 133:
17892 temp_combo.tile = 131;
17893 break;
17894 }
17895 8192 }
17896 474026 }
17897
17898
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 15)
17899 804325 temp_combo.o_tile = temp_combo.tile;
17900
17901
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version<18) //upper bits for .walk
17902 804325 temp_combo.walk |= 0xF0;
17903
17904
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 19)
17905
2/2
✓ Branch 0 taken 3217300 times.
✓ Branch 1 taken 804325 times.
4021625 for(int32_t q = 0; q < 4; ++q)
17906 4021625 temp_combo.attributes[q] *= 10000L;
17907
17908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 23)
17909 {
17910
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 872825 times.
873209 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17911 {
17912 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17913 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17914 case cTRIGGERGENERIC: case cCSWITCH:
17915 384 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17916 384 }
17917 873209 }
17918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 25)
17919 {
17920
2/2
✓ Branch 0 taken 3061 times.
✓ Branch 1 taken 870148 times.
873209 switch(temp_combo.type)
17921 {
17922 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3061 times.
3061 if(!(temp_combo.usrflags & cflag3))
17924 3061 temp_combo.attribytes[3] = WAV_DOOR;
17925 3061 temp_combo.usrflags &= ~cflag3;
17926 3061 break;
17927 }
17928 873209 }
17929
17930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 26)
17931
2/2
✓ Branch 0 taken 872622 times.
✓ Branch 1 taken 587 times.
873796 if(temp_combo.type == cARMOS)
17932
1/2
✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
587 if(temp_combo.usrflags & cflag1)
17933 temp_combo.usrflags |= cflag3;
17934
17935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 27)
17936 {
17937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17938 temp_combo.trigchange = 1;
17939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17940 temp_combo.trigchange = -1;
17941 873209 else temp_combo.trigchange = 0;
17942 873209 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17943 873209 }
17944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 28)
17945 {
17946
2/2
✓ Branch 0 taken 1689 times.
✓ Branch 1 taken 871520 times.
873209 switch(temp_combo.type)
17947 {
17948 case cLOCKBLOCK: case cLOCKEDCHEST:
17949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1689 times.
1689 if(temp_combo.usrflags & cflag7)
17950 temp_combo.usrflags |= cflag8;
17951 1689 else temp_combo.usrflags &= ~cflag8;
17952 1689 temp_combo.usrflags &= ~cflag7;
17953 1689 break;
17954 }
17955
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 873140 times.
873209 switch(temp_combo.type)
17956 {
17957 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17958 69 temp_combo.attrishorts[2] = -1;
17959 69 temp_combo.usrflags |= cflag7;
17960 69 break;
17961 }
17962 873209 }
17963
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 20)
17964 {
17965 804325 temp_combo.genflags = 0;
17966
2/2
✓ Branch 0 taken 19291 times.
✓ Branch 1 taken 785034 times.
804325 switch(temp_combo.type)
17967 {
17968 case cPUSH_WAIT: case cPUSH_HEAVY:
17969 case cPUSH_HW: case cL_STATUE:
17970 case cR_STATUE: case cPUSH_HEAVY2:
17971 case cPUSH_HW2: case cPOUND:
17972 case cC_STATUE: case cMIRROR:
17973 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17974 case cMAGICPRISM: case cMAGICPRISM4:
17975 case cMAGICSPONGE: case cEYEBALL_A:
17976 case cEYEBALL_B: case cEYEBALL_4:
17977 case cBUSH: case cFLOWERS:
17978 case cLOCKBLOCK: case cLOCKBLOCK2:
17979 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17980 case cCHEST: case cCHEST2:
17981 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17982 case cBOSSCHEST: case cBOSSCHEST2:
17983 case cBUSHNEXT: case cBUSHTOUCHY:
17984 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17985 case cSIGNPOST: case cCSWITCHBLOCK:
17986 case cTORCH: case cTRIGGERGENERIC:
17987
1/2
✓ Branch 0 taken 19291 times.
✗ Branch 1 not taken.
19291 if(temp_combo.usrflags & cflag16)
17988 {
17989 temp_combo.genflags |= cflag1;
17990 temp_combo.usrflags &= ~cflag16;
17991 }
17992 19291 break;
17993 }
17994 804325 }
17995
17996 873209 update_combo(temp_combo, section_version);
17997
17998
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 if(i>=start_combo)
17999 {
18000
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 combobuf[i] = temp_combo;
18001 873209 }
18002 873209 }
18003
18004
3/6
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 91 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
95 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18005 {
18006
2/2
✓ Branch 0 taken 261120 times.
✓ Branch 1 taken 4 times.
261124 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18007 {
18008
1/2
✓ Branch 0 taken 261120 times.
✗ Branch 1 not taken.
261120 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18009 {
18010 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18011 }
18012 261120 }
18013 4 }
18014
18015 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18016
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
95 if(version == 0x210 && !is_zquest())
18017 {
18018
2/2
✓ Branch 0 taken 783360 times.
✓ Branch 1 taken 12 times.
783372 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18019
2/2
✓ Branch 0 taken 783351 times.
✓ Branch 1 taken 9 times.
783369 if(combobuf[tmpcounter].type == cLADDERONLY)
18020 9 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18021 12 }
18022
18023
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 16 times.
95 if(section_version<7)
18024 {
18025
2/2
✓ Branch 0 taken 1044480 times.
✓ Branch 1 taken 16 times.
1044496 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18026 {
18027
6/9
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 174 times.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 45 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1043840 times.
1044480 switch(combobuf[tmpcounter].type)
18028 {
18029 case cSLASH:
18030 250 combobuf[tmpcounter].type=cSLASHTOUCHY;
18031 250 break;
18032
18033 case cSLASHITEM:
18034 174 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18035 174 break;
18036
18037 case cBUSH:
18038 126 combobuf[tmpcounter].type=cBUSHTOUCHY;
18039 126 break;
18040
18041 case cFLOWERS:
18042 45 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18043 45 break;
18044
18045 case cTALLGRASS:
18046 45 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18047 45 break;
18048
18049 case cSLASHNEXT:
18050 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18051 break;
18052
18053 case cSLASHNEXTITEM:
18054 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18055 break;
18056
18057 case cBUSHNEXT:
18058 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18059 break;
18060 }
18061 1044480 }
18062 16 }
18063
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 93 times.
95 if (section_version < 16)
18064 {
18065
2/2
✓ Branch 0 taken 6071040 times.
✓ Branch 1 taken 93 times.
6071133 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18066 {
18067
2/2
✓ Branch 0 taken 6062986 times.
✓ Branch 1 taken 8054 times.
6071040 if (combobuf[tmpcounter].type == cWATER)
18068 {
18069 8054 combobuf[tmpcounter].attributes[0] = 40000L;
18070 8054 }
18071 6071040 }
18072 93 }
18073
3/4
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 1 times.
95 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18074 {
18075 1 combobuf[0].walk = 0xF0;
18076 1 combobuf[0].type = 0;
18077 1 combobuf[0].flag = 0;
18078 1 }
18079
18080 //Now for the new combo alias reset
18081
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 16 times.
95 if(section_version<2)
18082 {
18083
2/2
✓ Branch 0 taken 131072 times.
✓ Branch 1 taken 16 times.
131088 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18084 {
18085 131072 combo_aliases[j].width = 0;
18086 131072 combo_aliases[j].height = 0;
18087 131072 combo_aliases[j].layermask = 0;
18088
18089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 if(combo_aliases[j].combos != NULL)
18090 {
18091
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 delete[] combo_aliases[j].combos;
18092 131072 }
18093
18094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 if(combo_aliases[j].csets != NULL)
18095 {
18096
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 delete[] combo_aliases[j].csets;
18097 131072 }
18098
18099
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 combo_aliases[j].combos = new word[1];
18100
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 combo_aliases[j].csets = new byte[1];
18101 131072 combo_aliases[j].combos[0] = 0;
18102 131072 combo_aliases[j].csets[0] = 0;
18103 131072 }
18104 16 }
18105
18106
18107
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 setup_combo_animations();
18108
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 setup_combo_animations2();
18109 95 return 0;
18110 95 }
18111 190484 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18112 {
18113 byte combo_has_flags;
18114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190484 times.
190484 if(!p_getc(&combo_has_flags,f))
18115 return qe_invalid;
18116
18117 190484 temp_combo.clear();
18118
2/2
✓ Branch 0 taken 123933 times.
✓ Branch 1 taken 66551 times.
190484 if(combo_has_flags)
18119 {
18120
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 66548 times.
66551 if(combo_has_flags&CHAS_BASIC)
18121 {
18122
1/2
✓ Branch 0 taken 66548 times.
✗ Branch 1 not taken.
66548 if(!p_igetl(&temp_combo.tile,f))
18123 {
18124 return qe_invalid;
18125 }
18126 66548 temp_combo.o_tile = temp_combo.tile;
18127
18128
1/2
✓ Branch 0 taken 66548 times.
✗ Branch 1 not taken.
66548 if(!p_getc(&temp_combo.flip,f))
18129 {
18130 return qe_invalid;
18131 }
18132
18133
1/2
✓ Branch 0 taken 66548 times.
✗ Branch 1 not taken.
66548 if(!p_getc(&temp_combo.walk,f))
18134 {
18135 return qe_invalid;
18136 }
18137
18138
1/2
✓ Branch 0 taken 66548 times.
✗ Branch 1 not taken.
66548 if(!p_getc(&temp_combo.type,f))
18139 {
18140 return qe_invalid;
18141 }
18142
18143
1/2
✓ Branch 0 taken 66548 times.
✗ Branch 1 not taken.
66548 if(!p_getc(&temp_combo.flag,f))
18144 {
18145 return qe_invalid;
18146 }
18147
18148
1/2
✓ Branch 0 taken 66548 times.
✗ Branch 1 not taken.
66548 if(!p_getc(&temp_combo.csets,f))
18149 {
18150 return qe_invalid;
18151 }
18152 66548 }
18153
2/2
✓ Branch 0 taken 66528 times.
✓ Branch 1 taken 23 times.
66551 if(combo_has_flags&CHAS_SCRIPT)
18154 {
18155
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 15 times.
23 if (s_version>=41)
18156 {
18157 8 p_getcstr(&temp_combo.label, f);
18158 8 }
18159 else
18160 {
18161 char label[12];
18162 15 label[11] = '\0';
18163
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 15 times.
180 for ( int32_t q = 0; q < 11; q++ )
18164 {
18165
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_getc(&label[q],f))
18166 {
18167 return qe_invalid;
18168 }
18169 165 }
18170 15 temp_combo.label = label;
18171 }
18172
18173
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
18174
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 23 times.
69 for ( int32_t q = 0; q < 2; q++ )
18175 {
18176
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if(!p_igetl(&temp_combo.initd[q],f))
18177 {
18178 return qe_invalid;
18179 }
18180 46 }
18181 23 }
18182
2/2
✓ Branch 0 taken 47800 times.
✓ Branch 1 taken 18751 times.
66551 if(combo_has_flags&CHAS_ANIM)
18183 {
18184
1/2
✓ Branch 0 taken 18751 times.
✗ Branch 1 not taken.
18751 if(!p_getc(&temp_combo.frames,f))
18185 {
18186 return qe_invalid;
18187 }
18188
18189
1/2
✓ Branch 0 taken 18751 times.
✗ Branch 1 not taken.
18751 if(!p_getc(&temp_combo.speed,f))
18190 {
18191 return qe_invalid;
18192 }
18193
18194
1/2
✓ Branch 0 taken 18751 times.
✗ Branch 1 not taken.
18751 if(!p_igetw(&temp_combo.nextcombo,f))
18195 {
18196 return qe_invalid;
18197 }
18198
18199
1/2
✓ Branch 0 taken 18751 times.
✗ Branch 1 not taken.
18751 if(!p_getc(&temp_combo.nextcset,f))
18200 {
18201 return qe_invalid;
18202 }
18203
18204
1/2
✓ Branch 0 taken 18751 times.
✗ Branch 1 not taken.
18751 if(!p_getc(&temp_combo.skipanim,f))
18205 {
18206 return qe_invalid;
18207 }
18208
18209
1/2
✓ Branch 0 taken 18751 times.
✗ Branch 1 not taken.
18751 if(!p_getc(&temp_combo.skipanimy,f))
18210 {
18211 return qe_invalid;
18212 }
18213
18214
1/2
✓ Branch 0 taken 18751 times.
✗ Branch 1 not taken.
18751 if(!p_getc(&temp_combo.animflags,f))
18215 {
18216 return qe_invalid;
18217 }
18218 18751 }
18219
2/2
✓ Branch 0 taken 58264 times.
✓ Branch 1 taken 8287 times.
66551 if(combo_has_flags&CHAS_ATTRIB)
18220 {
18221
2/2
✓ Branch 0 taken 33148 times.
✓ Branch 1 taken 8287 times.
41435 for ( int32_t q = 0; q < 4; q++ )
18222 {
18223
1/2
✓ Branch 0 taken 33148 times.
✗ Branch 1 not taken.
33148 if(!p_igetl(&temp_combo.attributes[q],f))
18224 {
18225 return qe_invalid;
18226 }
18227 33148 }
18228
2/2
✓ Branch 0 taken 66296 times.
✓ Branch 1 taken 8287 times.
74583 for ( int32_t q = 0; q < 8; q++ )
18229 {
18230
1/2
✓ Branch 0 taken 66296 times.
✗ Branch 1 not taken.
66296 if(!p_getc(&temp_combo.attribytes[q],f))
18231 {
18232 return qe_invalid;
18233 }
18234 66296 }
18235
2/2
✓ Branch 0 taken 66296 times.
✓ Branch 1 taken 8287 times.
74583 for ( int32_t q = 0; q < 8; q++ )
18236 {
18237
1/2
✓ Branch 0 taken 66296 times.
✗ Branch 1 not taken.
66296 if(!p_igetw(&temp_combo.attrishorts[q],f))
18238 {
18239 return qe_invalid;
18240 }
18241 66296 }
18242 8287 }
18243
2/2
✓ Branch 0 taken 64767 times.
✓ Branch 1 taken 1784 times.
66551 if(combo_has_flags&CHAS_FLAG)
18244 {
18245
1/2
✓ Branch 0 taken 1784 times.
✗ Branch 1 not taken.
1784 if(!p_igetl(&temp_combo.usrflags,f))
18246 {
18247 return qe_invalid;
18248 }
18249
1/2
✓ Branch 0 taken 1784 times.
✗ Branch 1 not taken.
1784 if(!p_igetw(&temp_combo.genflags,f))
18250 {
18251 return qe_invalid;
18252 }
18253 1784 }
18254
2/2
✓ Branch 0 taken 66022 times.
✓ Branch 1 taken 529 times.
66551 if(combo_has_flags&CHAS_TRIG)
18255 {
18256 529 int numtrigs = s_version < 36 ? 3 : 6;
18257
2/2
✓ Branch 0 taken 2745 times.
✓ Branch 1 taken 529 times.
3274 for ( int32_t q = 0; q < numtrigs; q++ )
18258 {
18259
1/2
✓ Branch 0 taken 2745 times.
✗ Branch 1 not taken.
2745 if(!p_igetl(&temp_combo.triggerflags[q],f))
18260 {
18261 return qe_invalid;
18262 }
18263 2745 }
18264
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_igetl(&temp_combo.triggerlevel,f))
18265 {
18266 return qe_invalid;
18267 }
18268
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.triggerbtn,f))
18269 {
18270 return qe_invalid;
18271 }
18272
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.triggeritem,f))
18273 {
18274 return qe_invalid;
18275 }
18276
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.trigtimer,f))
18277 {
18278 return qe_invalid;
18279 }
18280
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.trigsfx,f))
18281 {
18282 return qe_invalid;
18283 }
18284
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_igetl(&temp_combo.trigchange,f))
18285 {
18286 return qe_invalid;
18287 }
18288
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_igetw(&temp_combo.trigprox,f))
18289 {
18290 return qe_invalid;
18291 }
18292
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.trigctr,f))
18293 {
18294 return qe_invalid;
18295 }
18296
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_igetl(&temp_combo.trigctramnt,f))
18297 {
18298 return qe_invalid;
18299 }
18300
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.triglbeam,f))
18301 {
18302 return qe_invalid;
18303 }
18304
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.trigcschange,f))
18305 {
18306 return qe_invalid;
18307 }
18308
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_igetw(&temp_combo.spawnitem,f))
18309 {
18310 return qe_invalid;
18311 }
18312
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_igetw(&temp_combo.spawnenemy,f))
18313 {
18314 return qe_invalid;
18315 }
18316
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.exstate,f))
18317 {
18318 return qe_invalid;
18319 }
18320
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_igetl(&temp_combo.spawnip,f))
18321 {
18322 return qe_invalid;
18323 }
18324
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.trigcopycat,f))
18325 {
18326 return qe_invalid;
18327 }
18328
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.trigcooldown,f))
18329 {
18330 return qe_invalid;
18331 }
18332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 529 times.
529 if(s_version >= 35)
18333 {
18334
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_igetw(&temp_combo.prompt_cid,f))
18335 {
18336 return qe_invalid;
18337 }
18338
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.prompt_cs,f))
18339 {
18340 return qe_invalid;
18341 }
18342
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_igetw(&temp_combo.prompt_x,f))
18343 {
18344 return qe_invalid;
18345 }
18346
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_igetw(&temp_combo.prompt_y,f))
18347 {
18348 return qe_invalid;
18349 }
18350 529 }
18351
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 386 times.
529 if(s_version >= 36)
18352 {
18353
1/2
✓ Branch 0 taken 386 times.
✗ Branch 1 not taken.
386 if(!p_getc(&temp_combo.trig_lstate,f))
18354 {
18355 return qe_invalid;
18356 }
18357
1/2
✓ Branch 0 taken 386 times.
✗ Branch 1 not taken.
386 if(!p_getc(&temp_combo.trig_gstate,f))
18358 {
18359 return qe_invalid;
18360 }
18361
1/2
✓ Branch 0 taken 386 times.
✗ Branch 1 not taken.
386 if(!p_igetl(&temp_combo.trig_statetime,f))
18362 {
18363 return qe_invalid;
18364 }
18365 386 }
18366
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 386 times.
529 if(s_version >= 37)
18367 {
18368
1/2
✓ Branch 0 taken 386 times.
✗ Branch 1 not taken.
386 if(!p_igetw(&temp_combo.trig_genscr,f))
18369 {
18370 return qe_invalid;
18371 }
18372 386 }
18373
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 312 times.
529 if(s_version >= 38)
18374 {
18375
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(!p_getc(&temp_combo.trig_group,f))
18376 {
18377 return qe_invalid;
18378 }
18379
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(!p_igetw(&temp_combo.trig_group_val,f))
18380 {
18381 return qe_invalid;
18382 }
18383 312 }
18384 529 }
18385
2/2
✓ Branch 0 taken 66432 times.
✓ Branch 1 taken 119 times.
66551 if(combo_has_flags&CHAS_LIFT)
18386 {
18387
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&temp_combo.liftcmb,f))
18388 return qe_invalid;
18389
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.liftcs,f))
18390 return qe_invalid;
18391
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&temp_combo.liftundercmb,f))
18392 return qe_invalid;
18393
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.liftundercs,f))
18394 return qe_invalid;
18395
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.liftdmg,f))
18396 return qe_invalid;
18397
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.liftlvl,f))
18398 return qe_invalid;
18399
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.liftitm,f))
18400 return qe_invalid;
18401
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.liftflags,f))
18402 return qe_invalid;
18403
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.liftgfx,f))
18404 return qe_invalid;
18405
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.liftsprite,f))
18406 return qe_invalid;
18407
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.liftsfx,f))
18408 return qe_invalid;
18409
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18410 return qe_invalid;
18411
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.liftbreaksfx,f))
18412 return qe_invalid;
18413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(s_version >= 34)
18414 {
18415
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.lifthei,f))
18416 return qe_invalid;
18417
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.lifttime,f))
18418 return qe_invalid;
18419 119 }
18420
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 112 times.
119 if(s_version >= 39)
18421 {
18422
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_combo.lift_parent_item,f))
18423 return qe_invalid;
18424 112 }
18425 119 }
18426
2/2
✓ Branch 0 taken 66535 times.
✓ Branch 1 taken 16 times.
66551 if(combo_has_flags&CHAS_GENERAL)
18427 {
18428
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_combo.speed_mult,f))
18429 return qe_invalid;
18430
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_combo.speed_div,f))
18431 return qe_invalid;
18432
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetzf(&temp_combo.speed_add,f))
18433 return qe_invalid;
18434
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(s_version >= 42)
18435 {
18436 if(!p_getc(&temp_combo.sfx_appear,f))
18437 return qe_invalid;
18438 if(!p_getc(&temp_combo.sfx_disappear,f))
18439 return qe_invalid;
18440 if(!p_getc(&temp_combo.sfx_loop,f))
18441 return qe_invalid;
18442 if(!p_getc(&temp_combo.sfx_walking,f))
18443 return qe_invalid;
18444 if(!p_getc(&temp_combo.sfx_standing,f))
18445 return qe_invalid;
18446 if(!p_getc(&temp_combo.spr_appear,f))
18447 return qe_invalid;
18448 if(!p_getc(&temp_combo.spr_disappear,f))
18449 return qe_invalid;
18450 if(!p_getc(&temp_combo.spr_walking,f))
18451 return qe_invalid;
18452 if(!p_getc(&temp_combo.spr_standing,f))
18453 return qe_invalid;
18454 }
18455 16 }
18456 66551 }
18457 190484 update_combo(temp_combo, s_version);
18458 190484 return 0;
18459 190484 }
18460 123 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18461 {
18462 123 word section_version=0;
18463 123 word section_cversion=0;
18464 123 word combos_used=0;
18465 int32_t dummy;
18466 byte padding;
18467 123 newcombo temp_combo;
18468
18469
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 reset_combo_animations();
18470
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 reset_combo_animations2();
18471
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 init_combo_classes();
18472
18473
2/2
✓ Branch 0 taken 8029440 times.
✓ Branch 1 taken 123 times.
8029563 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18474
1/2
✓ Branch 0 taken 8029440 times.
✗ Branch 1 not taken.
8029440 combobuf[q].clear();
18475
18476
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
123 if(version > 0x192) //Version info
18477 {
18478
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!p_igetw(&section_version,f))
18479 {
18480 return qe_invalid;
18481 }
18482 119 FFCore.quest_format[vCombos] = section_version;
18483
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!p_igetw(&section_cversion,f))
18484 {
18485 return qe_invalid;
18486 }
18487
18488 //section size
18489
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!p_igetl(&dummy,f))
18490 {
18491 return qe_invalid;
18492 }
18493 119 }
18494
18495
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 95 times.
123 if(section_version > 32) //Cleanup time!
18496 {
18497
2/4
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
28 if(!p_igetw(&combos_used,f))
18498 {
18499 return qe_invalid;
18500 }
18501
2/2
✓ Branch 0 taken 190484 times.
✓ Branch 1 taken 28 times.
190512 for(int32_t i=0; i<combos_used; i++)
18502 {
18503
1/2
✓ Branch 0 taken 190484 times.
✗ Branch 1 not taken.
190484 auto ret = readcombo_loop(f,section_version,temp_combo);
18504
1/2
✓ Branch 0 taken 190484 times.
✗ Branch 1 not taken.
190484 if(ret) return ret;
18505
1/2
✓ Branch 0 taken 190484 times.
✗ Branch 1 not taken.
190484 if(i>=start_combo)
18506
1/2
✓ Branch 0 taken 190484 times.
✗ Branch 1 not taken.
190484 combobuf[i] = temp_combo;
18507 190484 }
18508 28 }
18509 else //Call the old function for all old versions
18510 {
18511
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18512
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 if(ret) return ret; //error, end read
18513 }
18514
18515
3/4
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 27 times.
123 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18516 {
18517 27 combobuf[0].walk = 0xF0;
18518 27 combobuf[0].type = 0;
18519 27 combobuf[0].flag = 0;
18520 27 }
18521
18522
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 setup_combo_animations();
18523
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 setup_combo_animations2();
18524 123 return 0;
18525 123 }
18526
18527 107 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18528 {
18529 //these are here to bypass compiler warnings about unused arguments
18530 107 Header=Header;
18531 107 version=version;
18532 107 build=build;
18533
18534 int32_t dummy;
18535 107 word sversion=0, c_sversion;
18536
18537 //section version info
18538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(!p_igetw(&sversion,f))
18539 {
18540 return qe_invalid;
18541 }
18542
18543 107 FFCore.quest_format[vComboAliases] = sversion;
18544
18545 //al_trace("Combo aliases version %d\n", sversion);
18546
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetw(&c_sversion,f))
18547 {
18548 return qe_invalid;
18549 }
18550
18551 //section size
18552
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetl(&dummy,f))
18553 {
18554 return qe_invalid;
18555 }
18556
18557 107 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18558
18559
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 77 times.
107 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18560 {
18561 77 max_num_combo_aliases = MAX250COMBOALIASES;
18562 77 }
18563
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18564 {
18565 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18566 }
18567
18568
2/2
✓ Branch 0 taken 403456 times.
✓ Branch 1 taken 107 times.
403563 for(int32_t j=0; j<max_num_combo_aliases; j++)
18569 {
18570 byte width,height,mask,tempcset;
18571 int32_t count;
18572 word tempword;
18573 byte tempbyte;
18574
18575
1/2
✓ Branch 0 taken 403456 times.
✗ Branch 1 not taken.
403456 if(!p_igetw(&tempword,f))
18576 {
18577 return qe_invalid;
18578 }
18579
18580 403456 combo_aliases[j].combo = tempword;
18581
18582
1/2
✓ Branch 0 taken 403456 times.
✗ Branch 1 not taken.
403456 if(!p_getc(&tempbyte,f))
18583 {
18584 return qe_invalid;
18585 }
18586
18587 403456 combo_aliases[j].cset = tempbyte;
18588
18589
1/2
✓ Branch 0 taken 403456 times.
✗ Branch 1 not taken.
403456 if(!p_getc(&width,f))
18590 {
18591 return qe_invalid;
18592 }
18593
18594
1/2
✓ Branch 0 taken 403456 times.
✗ Branch 1 not taken.
403456 if(!p_getc(&height,f))
18595 {
18596 return qe_invalid;
18597 }
18598
18599
1/2
✓ Branch 0 taken 403456 times.
✗ Branch 1 not taken.
403456 if(!p_getc(&mask,f))
18600 {
18601 return qe_invalid;
18602 }
18603
18604 403456 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18605
18606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 403456 times.
403456 if(combo_aliases[j].combos != NULL)
18607 {
18608
1/2
✓ Branch 0 taken 403456 times.
✗ Branch 1 not taken.
403456 delete[] combo_aliases[j].combos;
18609 403456 }
18610
18611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 403456 times.
403456 if(combo_aliases[j].csets != NULL)
18612 {
18613
1/2
✓ Branch 0 taken 403456 times.
✗ Branch 1 not taken.
403456 delete[] combo_aliases[j].csets;
18614 403456 }
18615
18616 403456 combo_aliases[j].width = width;
18617 403456 combo_aliases[j].height = height;
18618 403456 combo_aliases[j].layermask = mask;
18619 403456 combo_aliases[j].combos = new word[count];
18620 403456 combo_aliases[j].csets = new byte[count];
18621
18622
2/2
✓ Branch 0 taken 413181 times.
✓ Branch 1 taken 403456 times.
816637 for(int32_t k=0; k<count; k++)
18623 {
18624
1/2
✓ Branch 0 taken 413181 times.
✗ Branch 1 not taken.
413181 if(!p_igetw(&tempword,f))
18625 {
18626 return qe_invalid;
18627 }
18628
18629 413181 combo_aliases[j].combos[k] = tempword;
18630 413181 }
18631
18632
2/2
✓ Branch 0 taken 413181 times.
✓ Branch 1 taken 403456 times.
816637 for(int32_t k=0; k<count; k++)
18633 {
18634
1/2
✓ Branch 0 taken 413181 times.
✗ Branch 1 not taken.
413181 if(!p_getc(&tempcset,f))
18635 {
18636 return qe_invalid;
18637 }
18638
18639 413181 combo_aliases[j].csets[k] = tempcset;
18640 413181 }
18641 403456 }
18642
18643 107 word num_combo_pools = 0;
18644
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 28 times.
107 if(sversion >= 4)
18645 {
18646
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_igetw(&num_combo_pools,f))
18647 {
18648 return qe_invalid;
18649 }
18650 28 }
18651
18652
2/2
✓ Branch 0 taken 876544 times.
✓ Branch 1 taken 107 times.
876651 for(combo_pool& pool : combo_pools)
18653 {
18654 876544 pool.clear();
18655 }
18656
18657 107 combo_pool temp_cpool;
18658
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 107 times.
182 for(word cp = 0; cp < num_combo_pools; ++cp)
18659 {
18660 75 int32_t num_combos_in_pool = 0;
18661
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if(!p_igetl(&num_combos_in_pool,f))
18662 {
18663 return qe_invalid;
18664 }
18665
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(num_combos_in_pool < 1) continue; //nothing to read
18666
18667
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cpool.clear();
18668
18669 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18670
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 325 times.
400 for(auto q = 0; q < num_combos_in_pool; ++q)
18671 {
18672
2/4
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 325 times.
✗ Branch 3 not taken.
325 if(!p_igetl(&cp_cid,f))
18673 {
18674 return qe_invalid;
18675 }
18676
2/4
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 325 times.
✗ Branch 3 not taken.
325 if(!p_getc(&cp_cs,f))
18677 {
18678 return qe_invalid;
18679 }
18680
2/4
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 325 times.
✗ Branch 3 not taken.
325 if(!p_igetw(&cp_quant,f))
18681 {
18682 return qe_invalid;
18683 }
18684
1/2
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
325 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18685 325 }
18686
18687
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 combo_pools[cp] = temp_cpool;
18688 75 }
18689
18690 107 return 0;
18691 107 }
18692
18693 123 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18694 {
18695 //these are here to bypass compiler warnings about unused arguments
18696
18697 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18698 //Capitalized cause it'll save you a headache. -Deedee
18699 123 start_cset=start_cset;
18700 123 max_csets=max_csets;
18701 123 word s_version=0;
18702
18703 miscQdata temp_misc;
18704 123 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18705
18706 byte temp_colordata[48];
18707 char temp_palname[PALNAMESIZE];
18708
18709 int32_t dummy;
18710 word palcycles;
18711
18712
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 119 times.
123 if(version > 0x192)
18713 {
18714 //section version info
18715
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&s_version,f))
18716 {
18717 return qe_invalid;
18718 }
18719
18720 119 FFCore.quest_format[vCSets] = s_version;
18721
18722 //al_trace("Color data version %d\n", s_version);
18723
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&dummy,f))
18724 {
18725 return qe_invalid;
18726 }
18727
18728 //section size
18729
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetl(&dummy,f))
18730 {
18731 return qe_invalid;
18732 }
18733 119 }
18734
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 30 times.
123 if (s_version < 5)
18735 {
18736
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
93 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18737
18738 //finally... section data
18739 93 int32_t q = 0;
18740 93 int32_t p = -15;
18741
2/2
✓ Branch 0 taken 22320 times.
✓ Branch 1 taken 93 times.
22413 for(int32_t i=0; i<oldpdTOTAL; ++i)
18742 {
18743 22320 memset(temp_colordata, 0, 48);
18744
18745
1/2
✓ Branch 0 taken 22320 times.
✗ Branch 1 not taken.
22320 if(!pfread(temp_colordata,48,f))
18746 {
18747 return qe_invalid;
18748 }
18749
18750 22320 memcpy(&colordata[q*48], temp_colordata, 48);
18751
18752 22320 ++q;
18753
8/8
✓ Branch 0 taken 20832 times.
✓ Branch 1 taken 1488 times.
✓ Branch 2 taken 1581 times.
✓ Branch 3 taken 19251 times.
✓ Branch 4 taken 186 times.
✓ Branch 5 taken 1395 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 178 times.
22320 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18754 {
18755
1/2
✓ Branch 0 taken 1573 times.
✗ Branch 1 not taken.
1573 if (s_version < 5) //Bumping up the size of level palettes
18756 {
18757 1573 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18758 1573 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18759 1573 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18760 1573 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18761 1573 q+=4;
18762 1573 }
18763 else
18764 {
18765 for(int m = 0; m < 4; ++m)
18766 {
18767 memset(temp_colordata, 0, 48);
18768 if(!pfread(temp_colordata,48,f))
18769 {
18770 return qe_invalid;
18771 }
18772 memcpy(&colordata[q*48], temp_colordata, 48);
18773 ++q;
18774 }
18775 }
18776 1573 }
18777 22320 ++p;
18778 22320 }
18779
18780
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
93 if(RealOldVerion)
18781 {
18782 4 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18783 4 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18784 4 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18785 4 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18786 4 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18787 4 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18788 4 }
18789 else
18790 {
18791 89 memset(temp_colordata, 0, 48);
18792
18793
2/2
✓ Branch 0 taken 278837 times.
✓ Branch 1 taken 89 times.
278926 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18794 {
18795
1/2
✓ Branch 0 taken 278837 times.
✗ Branch 1 not taken.
278837 if(!pfread(temp_colordata,48,f))
18796 {
18797 return qe_invalid;
18798 }
18799
18800 278837 memcpy(&colordata[q*48], temp_colordata, 48);
18801
18802 278837 ++q;
18803
7/8
✓ Branch 0 taken 278837 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21449 times.
✓ Branch 3 taken 257388 times.
✓ Branch 4 taken 178 times.
✓ Branch 5 taken 21271 times.
✓ Branch 6 taken 154 times.
✓ Branch 7 taken 24 times.
278837 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18804 {
18805
1/2
✓ Branch 0 taken 21425 times.
✗ Branch 1 not taken.
21425 if (s_version < 5) //Bumping up the size of level palettes
18806 {
18807 21425 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18808 21425 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18809 21425 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18810 21425 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18811 21425 q+=4;
18812 21425 }
18813 else
18814 {
18815 for(int m = 0; m < 4; ++m)
18816 {
18817 memset(temp_colordata, 0, 48);
18818 if(!pfread(temp_colordata,48,f))
18819 {
18820 return qe_invalid;
18821 }
18822 memcpy(&colordata[q*48], temp_colordata, 48);
18823 ++q;
18824 }
18825 }
18826 21425 }
18827 278837 ++p;
18828 278837 }
18829
18830
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 77 times.
89 if(s_version < 4)
18831 {
18832 12 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18833 12 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18834 12 }
18835 else
18836 {
18837
2/2
✓ Branch 0 taken 256256 times.
✓ Branch 1 taken 77 times.
256333 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18838 {
18839
1/2
✓ Branch 0 taken 256256 times.
✗ Branch 1 not taken.
256256 if(!pfread(temp_colordata,48,f))
18840 {
18841 return qe_invalid;
18842 }
18843
18844 256256 memcpy(&colordata[q*48], temp_colordata, 48);
18845 256256 ++q;
18846
5/6
✓ Branch 0 taken 256256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19712 times.
✓ Branch 3 taken 236544 times.
✓ Branch 4 taken 154 times.
✓ Branch 5 taken 19558 times.
256256 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18847 {
18848
1/2
✓ Branch 0 taken 19558 times.
✗ Branch 1 not taken.
19558 if (s_version < 5) //Bumping up the size of level palettes
18849 {
18850 19558 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18851 19558 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18852 19558 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18853 19558 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18854 19558 q+=4;
18855 19558 }
18856 else
18857 {
18858 for(int m = 0; m < 4; ++m)
18859 {
18860 memset(temp_colordata, 0, 48);
18861 if(!pfread(temp_colordata,48,f))
18862 {
18863 return qe_invalid;
18864 }
18865 memcpy(&colordata[q*48], temp_colordata, 48);
18866 ++q;
18867 }
18868 }
18869 19558 }
18870 256256 ++p;
18871 256256 }
18872
18873 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18874 }
18875 }
18876 93 }
18877 else
18878 {
18879
2/2
✓ Branch 0 taken 262470 times.
✓ Branch 1 taken 30 times.
262500 for(int32_t i=0; i<pdTOTAL255; ++i)
18880 {
18881 262470 memset(temp_colordata, 0, 48);
18882
18883
1/2
✓ Branch 0 taken 262470 times.
✗ Branch 1 not taken.
262470 if(!pfread(temp_colordata,48,f))
18884 {
18885 return qe_invalid;
18886 }
18887
18888 262470 memcpy(&colordata[i*48], temp_colordata, 48);
18889 262470 }
18890 }
18891
18892
3/6
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
123 if((version < 0x192)||((version == 0x192)&&(build<76)))
18893 {
18894 4 init_palnames();
18895 4 }
18896 else
18897 {
18898 119 int32_t palnamestoread = 0;
18899
18900
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 107 times.
119 if(s_version < 3)
18901 12 palnamestoread = OLDMAXLEVELS;
18902 else
18903 107 palnamestoread = 512;
18904
18905
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 119 times.
57975 for(int32_t i=0; i<palnamestoread; ++i)
18906 {
18907 57856 memset(temp_palname, 0, PALNAMESIZE);
18908
18909
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!pfread(temp_palname,PALNAMESIZE,f))
18910 {
18911 return qe_invalid;
18912 }
18913
18914 57856 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18915 57856 }
18916
18917
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 119 times.
3191 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18918 {
18919 3072 memset(palnames[i], 0, PALNAMESIZE);
18920 3072 }
18921 }
18922
18923
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 119 times.
123 if(version > 0x192)
18924 {
18925
2/2
✓ Branch 0 taken 30464 times.
✓ Branch 1 taken 119 times.
30583 for(int32_t i=0; i<256; i++)
18926 {
18927
2/2
✓ Branch 0 taken 91392 times.
✓ Branch 1 taken 30464 times.
121856 for(int32_t j=0; j<3; j++)
18928 {
18929 91392 temp_misc.cycles[i][j].first=0;
18930 91392 temp_misc.cycles[i][j].count=0;
18931 91392 temp_misc.cycles[i][j].speed=0;
18932 91392 }
18933 30464 }
18934
18935
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&palcycles,f))
18936 {
18937 return qe_invalid;
18938 }
18939
18940
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
119 if (!(palcycles >= 0 && palcycles <= NUM_PAL_CYCLES))
18941 {
18942 return qe_invalid;
18943 }
18944
18945
2/2
✓ Branch 0 taken 3576 times.
✓ Branch 1 taken 119 times.
3695 for(int32_t i=0; i<palcycles; i++)
18946 {
18947
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18948 {
18949
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].first,f))
18950 {
18951 return qe_invalid;
18952 }
18953 10728 }
18954
18955
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18956 {
18957
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].count,f))
18958 {
18959 return qe_invalid;
18960 }
18961 10728 }
18962
18963
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18964 {
18965
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
18966 {
18967 return qe_invalid;
18968 }
18969 10728 }
18970 3576 }
18971
18972 119 memcpy(Misc, &temp_misc, sizeof(temp_misc));
18973 119 }
18974
18975 123 return 0;
18976 123 }
18977
18978 123 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
18979 {
18980 123 int32_t tiles_used=0;
18981 123 word section_version = 0;
18982 123 word section_cversion = 0;
18983 123 int32_t section_size= 0;
18984 123 byte *temp_tile = new byte[tilesize(tf32Bit)];
18985
18986 //Tile Expansion
18987 //if ( version >= 0x254 && build >= 41 )
18988
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
123 if (version < 0x254 && build < 41)
18989 {
18990 //al_trace("Build was < 41 when reading tiles\n");
18991 93 max_tiles = ZC250MAXTILES;
18992 93 }
18993
18994 //al_trace("Max Tiles: %d\n", max_tiles);
18995
18996
2/6
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 123 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
123 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
18997 {
18998 if(!init_tiles(true, Header))
18999 {
19000 al_trace("Unable to initialize tiles\n");
19001 }
19002
19003 delete[] temp_tile;
19004 temp_tile=NULL;
19005 return 0;
19006 }
19007 else
19008 {
19009
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 119 times.
123 if(version > 0x192)
19010 {
19011 //section version info
19012
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&section_version,f))
19013 {
19014 delete[] temp_tile;
19015 return qe_invalid;
19016 }
19017
19018 119 FFCore.quest_format[vTiles] = section_version;
19019
19020
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&section_cversion,f))
19021 {
19022 delete[] temp_tile;
19023 return qe_invalid;
19024 }
19025
19026 //section size
19027
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetl(&section_size,f))
19028 {
19029 delete[] temp_tile;
19030 return qe_invalid;
19031 }
19032 119 }
19033
19034 //if ( build < 41 )
19035 //{
19036 // tiles_used = ZC250MAXTILES;
19037 //}
19038
19039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(version < 0x174)
19040 {
19041 tiles_used=TILES_PER_PAGE*4;
19042 } //no expanded tile space
19043
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 119 times.
123 else if(version < 0x191)
19044 {
19045 4 tiles_used=OLDMAXTILES;
19046 4 }
19047 else
19048 {
19049 //finally... section data
19050
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
119 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19051 {
19052
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tiles_used,f))
19053 {
19054 delete[] temp_tile;
19055 return qe_invalid;
19056 }
19057 30 }
19058 else
19059 {
19060
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(!p_igetw(&tiles_used,f))
19061 {
19062 delete[] temp_tile;
19063 return qe_invalid;
19064 }
19065 }
19066 }
19067
19068
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 tiles_used=zc_min(tiles_used, max_tiles);
19069
19070 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19071 //if ( version < 0x254 && build < 41 )
19072
3/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
123 if ( version < 0x254 || (version == 0x254 && build < 41) )
19073 //if ( build < 41 )
19074 {
19075
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19076 93 }
19077 else //2.55
19078 {
19079
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19080 }
19081
19082 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19083
19084 //al_trace("tiles_used = %d\n", tiles_used);
19085
19086
2/2
✓ Branch 0 taken 3211328 times.
✓ Branch 1 taken 123 times.
3211451 for(int32_t i=0; i<tiles_used; ++i)
19087 {
19088 3211328 byte format=tf4Bit;
19089 3211328 memset(temp_tile, 0, tilesize(tf32Bit));
19090
19091
3/6
✓ Branch 0 taken 630780 times.
✓ Branch 1 taken 2580548 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 630780 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3211328 if((version>0x211)||((version==0x211)&&(build>4)))
19092 {
19093
1/2
✓ Branch 0 taken 2580548 times.
✗ Branch 1 not taken.
2580548 if(!p_getc(&format,f))
19094 {
19095 delete[] temp_tile;
19096 return qe_invalid;
19097 }
19098 2580548 }
19099
4/4
✓ Branch 0 taken 1030994 times.
✓ Branch 1 taken 2180334 times.
✓ Branch 2 taken 508127 times.
✓ Branch 3 taken 522867 times.
3211328 if(section_version > 2 && !format)
19100 {
19101 522867 reset_tile(buf,start_tile+i,tf4Bit);
19102 522867 continue;
19103 }
19104
19105
1/2
✓ Branch 0 taken 2688461 times.
✗ Branch 1 not taken.
2688461 if(!pfread(temp_tile,tilesize(format),f))
19106 {
19107 delete[] temp_tile;
19108 return qe_invalid;
19109 }
19110
19111 2688461 buf[start_tile+i].format=format;
19112
19113
1/2
✓ Branch 0 taken 2688461 times.
✗ Branch 1 not taken.
2688461 if(buf[start_tile+i].data)
19114 {
19115 2688461 free(buf[start_tile+i].data);
19116 2688461 buf[start_tile+i].data=NULL;
19117 2688461 }
19118
19119 2688461 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19120 2688461 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19121 2688461 }
19122 }
19123
19124
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19125 {
19126 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19127
2/2
✓ Branch 0 taken 13855140 times.
✓ Branch 1 taken 93 times.
13855233 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19128 {
19129
19130 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19131 13855140 reset_tile(buf,q,tf4Bit);
19132
19133
19134 /*
19135
19136 byte tempbyte;
19137 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19138 {
19139 tempbyte=buf[ZC250MAXTILES-1].data[i];
19140 buf[q].data[i] = tempbyte;
19141 }
19142 //int32_t temp = tempbyte=buf[130].data[i];
19143 //buf[q].data = buf[ZC250MAXTILES-1].data;
19144 */
19145 //reset_tile(buf,q,tf4Bit);
19146 13855140 }
19147
19148 93 }
19149
19150
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
123 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19151 {
19152
2/2
✓ Branch 0 taken 4121646 times.
✓ Branch 1 taken 93 times.
4121739 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19153 {
19154 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19155 4121646 reset_tile(buf,i,tf4Bit);
19156 4121646 }
19157 93 }
19158 else
19159 {
19160
2/2
✓ Branch 0 taken 5195386 times.
✓ Branch 1 taken 30 times.
5195416 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19161 {
19162 //al_trace("Resetting tiles for build 41+\n");
19163 5195386 reset_tile(buf,i,tf4Bit);
19164 5195386 }
19165 }
19166
19167
3/6
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
123 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19168 {
19169
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_qr(qr_BSZELDA)) //
19170 {
19171 byte tempbyte;
19172 int32_t floattile=wpnsbuf[iwSwim].tile;
19173
19174 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19175 {
19176 tempbyte=buf[23].data[i];
19177 buf[23].data[i]=buf[24].data[i];
19178 buf[24].data[i]=buf[25].data[i];
19179 buf[25].data[i]=buf[26].data[i];
19180 buf[26].data[i]=tempbyte;
19181 }
19182 //swim tiles are out of order, too, but nobody cared? -Z
19183 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19184 {
19185 tempbyte=buf[floattile+11].data[i];
19186 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19187 buf[floattile+12].data[i]=tempbyte;
19188 }
19189 }
19190 4 }
19191
19192
3/6
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 107 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
123 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19193 {
19194
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(!get_qr(qr_NEWENEMYTILES))
19195 {
19196 byte tempbyte;
19197
19198
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19199 {
19200 512 tempbyte=buf[130].data[i];
19201 512 buf[130].data[i]=buf[132].data[i];
19202 512 buf[132].data[i]=tempbyte;
19203
19204 512 tempbyte=buf[131].data[i];
19205 512 buf[131].data[i]=buf[133].data[i];
19206 512 buf[133].data[i]=tempbyte;
19207 512 }
19208 4 }
19209 16 }
19210
19211 123 al_trace("Registering blank tiles\n");
19212 123 register_blank_tiles();
19213
19214 //memset(temp_tile, 0, tilesize(tf32Bit));
19215
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 delete[] temp_tile;
19216 123 temp_tile=NULL;
19217 123 return 0;
19218 123 }
19219
19220 123 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19221 {
19222 123 byte *mf=midi_flags;
19223 int32_t dummy;
19224 word dummy2;
19225 // zcmidi_ temp_midi;
19226 int32_t tunes_to_read;
19227 123 int32_t tune_count=0;
19228 123 word section_version=0;
19229 123 zctune temp;
19230
19231
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 119 times.
123 if(Header->zelda_version < 0x193)
19232 {
19233 // mf=Header->data_flags+ZQ_MIDIS2;
19234
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19235 {
19236 4 tunes_to_read=MAXCUSTOMMIDIS192b177;
19237 4 }
19238 else
19239 {
19240 tunes_to_read=MAXCUSTOMTUNES;
19241 }
19242 4 }
19243 else
19244 {
19245 //section version info
19246
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&section_version,f))
19247 {
19248 return qe_invalid;
19249 }
19250
19251 119 FFCore.quest_format[vMIDIs] = section_version;
19252
19253 //al_trace("Tunes version %d\n", section_version);
19254
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&dummy2,f))
19255 {
19256 return qe_invalid;
19257 }
19258
19259 //section size
19260
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetl(&dummy,f))
19261 {
19262 return qe_invalid;
19263 }
19264
19265 //finally... section data
19266
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!pfread(midi_flags,sizeof(midi_flags),f))
19267 {
19268 return qe_invalid;
19269 }
19270
19271 119 tunes_to_read=MAXCUSTOMTUNES;
19272 }
19273
19274
2/2
✓ Branch 0 taken 30996 times.
✓ Branch 1 taken 123 times.
31119 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19275 {
19276
2/2
✓ Branch 0 taken 28700 times.
✓ Branch 1 taken 2296 times.
30996 if(get_bit(mf, i))
19277 {
19278 2296 ++tune_count;
19279 2296 }
19280 30996 }
19281
19282 123 reset_tunes(tunes); //reset_midis(midis);
19283
19284
2/2
✓ Branch 0 taken 30116 times.
✓ Branch 1 taken 123 times.
30239 for(int32_t i=0; i<tunes_to_read; i++)
19285 {
19286 30116 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19287
19288 30116 tunes[i].reset(); // reset_midi(midis+i);
19289
19290
2/2
✓ Branch 0 taken 27820 times.
✓ Branch 1 taken 2296 times.
30116 if(get_bit(mf,i))
19291 {
19292
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1579 times.
2296 if(section_version < 4)
19293 {
19294
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if(!pfread(&temp.title,sizeof(char)*20,f))
19295 {
19296 return qe_invalid;
19297 }
19298 717 }
19299 else
19300 {
19301
1/2
✓ Branch 0 taken 1579 times.
✗ Branch 1 not taken.
1579 if(!pfread(&temp.title,sizeof(temp.title),f))
19302 {
19303 return qe_invalid;
19304 }
19305 }
19306
19307
1/2
✓ Branch 0 taken 2296 times.
✗ Branch 1 not taken.
2296 if(!p_igetl(&temp.start,f))
19308 {
19309 return qe_invalid;
19310 }
19311
19312
1/2
✓ Branch 0 taken 2296 times.
✗ Branch 1 not taken.
2296 if(!p_igetl(&temp.loop_start,f))
19313 {
19314 return qe_invalid;
19315 }
19316
19317
1/2
✓ Branch 0 taken 2296 times.
✗ Branch 1 not taken.
2296 if(!p_igetl(&temp.loop_end,f))
19318 {
19319 return qe_invalid;
19320 }
19321
19322
1/2
✓ Branch 0 taken 2296 times.
✗ Branch 1 not taken.
2296 if(!p_igetw(&temp.loop,f))
19323 {
19324 return qe_invalid;
19325 }
19326
19327
1/2
✓ Branch 0 taken 2296 times.
✗ Branch 1 not taken.
2296 if(!p_igetw(&temp.volume,f))
19328 {
19329 return qe_invalid;
19330 }
19331
19332
2/2
✓ Branch 0 taken 2218 times.
✓ Branch 1 taken 78 times.
2296 if(Header->zelda_version < 0x193)
19333 {
19334
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 if(!p_igetl(&dummy,f))
19335 {
19336 return qe_invalid;
19337 }
19338 78 }
19339
19340
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1579 times.
2296 if(section_version >= 3)
19341 {
19342
1/2
✓ Branch 0 taken 1579 times.
✗ Branch 1 not taken.
1579 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19343 {
19344 return qe_invalid;
19345 }
19346 1579 }
19347
19348 2296 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19349
19350
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1579 times.
2296 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19351 {
19352 // old format - a midi is a midi
19353
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if((tunes[i].data=read_midi(f))==NULL)
19354 {
19355 return qe_invalid;
19356 }
19357
19358 //yes you can do this. Isn't the ? operator awesome? :)
19359 717 tunes[i].format = MFORMAT_MIDI;
19360 717 }
19361 else
19362 {
19363 // 'midi' could be midi or nes, gb, ... music
19364
1/2
✓ Branch 0 taken 1579 times.
✗ Branch 1 not taken.
1579 if(!pfread(&tunes[i].format,sizeof(tunes[i].format),f))
19365 {
19366 return qe_invalid;
19367 }
19368
19369 1579 zctune *ptr = &tunes[i];
19370
19371
1/2
✓ Branch 0 taken 1579 times.
✗ Branch 1 not taken.
1579 switch(temp.format)
19372 {
19373 case MFORMAT_MIDI:
19374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1579 times.
1579 if((ptr->data=read_midi(f))==NULL)
19375 {
19376 return qe_invalid;
19377 }
19378
19379 1579 break;
19380
19381 default:
19382 return qe_invalid;
19383 break;
19384 }
19385 }
19386 2296 }
19387 30116 }
19388
19389 123 return 0;
19390 123 }
19391
19392 123 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19393 {
19394 int32_t dummy;
19395 ZCHEATS tempzcheats;
19396 123 char temp_use_cheats=1;
19397 123 memset(&tempzcheats, 0, sizeof(tempzcheats));
19398 123 word s_version = 0;
19399
19400
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 119 times.
123 if(Header->zelda_version > 0x192)
19401 {
19402 //section version info
19403
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&s_version,f))
19404 {
19405 return qe_invalid;
19406 }
19407
19408 119 FFCore.quest_format[vCheats] = s_version;
19409 //al_trace("Cheats version %d\n", dummy);
19410
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&dummy,f))
19411 {
19412 return qe_invalid;
19413 }
19414
19415 //section size
19416
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetl(&dummy,f))
19417 {
19418 return qe_invalid;
19419 }
19420
19421 //finally... section data
19422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(!p_getc(&temp_use_cheats,f))
19423 {
19424 return qe_invalid;
19425 }
19426 119 }
19427
19428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(Header->data_flags[ZQ_CHEATS2])
19429 {
19430
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(!p_igetl(&tempzcheats.flags,f))
19431 {
19432 return qe_invalid;
19433 }
19434
19435
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19436 {
19437 return qe_invalid;
19438 }
19439 123 }
19440
19441 123 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19442 123 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19443
19444 123 return 0;
19445 123 }
19446
19447 301 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
19448 {
19449 int32_t dummy;
19450 301 word s_version=0, s_cversion=0;
19451 byte padding;
19452
19453 301 zinitdata temp_zinit;
19454
19455 // Legacy item properties (now integrated into itemdata)
19456 byte sword_hearts[4];
19457 byte beam_hearts[4];
19458 301 byte beam_percent=0;
19459 word beam_power[4];
19460 301 byte hookshot_length=99;
19461 301 byte hookshot_links=100;
19462 301 byte longshot_length=99;
19463 301 byte longshot_links=100;
19464 301 byte moving_fairy_hearts=3;
19465 301 byte moving_fairy_heart_percent=0;
19466 301 byte stationary_fairy_hearts=3;
19467 301 byte stationary_fairy_heart_percent=0;
19468 301 byte moving_fairy_magic=0;
19469 301 byte moving_fairy_magic_percent=0;
19470 301 byte stationary_fairy_magic=0;
19471 301 byte stationary_fairy_magic_percent=0;
19472 301 byte blue_potion_hearts=100;
19473 301 byte blue_potion_heart_percent=1;
19474 301 byte red_potion_hearts=100;
19475 301 byte red_potion_heart_percent=1;
19476 301 byte blue_potion_magic=100;
19477 301 byte blue_potion_magic_percent=1;
19478 301 byte red_potion_magic=100;
19479 301 byte red_potion_magic_percent=1;
19480
19481
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 178 times.
301 temp_zinit.subscreen_style=get_qr(qr_COOLSCROLL)?1:0;
19482
19483
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
123 if(Header->zelda_version > 0x192)
19484 {
19485 //section version info
19486
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!p_igetw(&s_version,f))
19487 {
19488 return qe_invalid;
19489 }
19490
19491 119 FFCore.quest_format[vInitData] = s_version;
19492
19493 //al_trace("Init data version %d\n", s_version);
19494
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!p_igetw(&s_cversion,f))
19495 {
19496 return qe_invalid;
19497 }
19498
19499 //section size
19500
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!p_igetl(&dummy,f))
19501 {
19502 return qe_invalid;
19503 }
19504 119 }
19505
19506 /* HIGHLY UNORTHODOX UPDATING THING, by L
19507 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19508 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19509 * changing from 13 to 14.
19510 */
19511
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if(s_version < 14)
19512 16 fixpolsvoice=true;
19513
19514 /* End highly unorthodox updating thing */
19515
19516
5/6
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75 times.
✓ Branch 5 taken 32 times.
123 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19517 32 temp_zinit.jump_hero_layer_threshold=0;
19518
19519
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 107 times.
123 if(s_version >= 10)
19520 {
19521 char temp;
19522
19523 //new-style items
19524
2/2
✓ Branch 0 taken 27392 times.
✓ Branch 1 taken 107 times.
27499 for(int32_t j=0; j<256; j++)
19525 {
19526
2/4
✓ Branch 0 taken 27392 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27392 times.
27392 if(!p_getc(&temp,f))
19527 return qe_invalid;
19528
19529 27392 temp_zinit.items[j] = (temp != 0);
19530 27392 }
19531 107 }
19532
19533
5/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 59 times.
✓ Branch 5 taken 59 times.
123 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19534 {
19535 char temp;
19536
19537 //finally... section data
19538
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 59 times.
178 if((Header->zelda_version > 0x192)||
19539 //new only
19540 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19541 {
19542 //OLD-style items... sigh
19543
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 107 times.
119 if(s_version < 10)
19544 {
19545
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19546 {
19547 return qe_invalid;
19548 }
19549
19550 12 temp_zinit.items[iRaft]=(temp != 0);
19551
19552
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19553 {
19554 return qe_invalid;
19555 }
19556
19557 12 temp_zinit.items[iLadder]=(temp != 0);
19558
19559
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19560 {
19561 return qe_invalid;
19562 }
19563
19564 12 temp_zinit.items[iBook]=(temp != 0);
19565
19566
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19567 {
19568 return qe_invalid;
19569 }
19570
19571 12 temp_zinit.items[iMKey]=(temp!=0);
19572
19573
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19574 {
19575 return qe_invalid;
19576 }
19577
19578 12 temp_zinit.items[iFlippers]=(temp != 0);
19579
19580
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19581 {
19582 return qe_invalid;
19583 }
19584
19585 12 temp_zinit.items[iBoots]=(temp!=0);
19586 12 }
19587 119 }
19588
19589
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 166 times.
178 if(s_version < 10)
19590 {
19591 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19592
19593
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempring,f))
19594 {
19595 return qe_invalid;
19596 }
19597
19598
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempsword,f))
19599 {
19600 return qe_invalid;
19601 }
19602
19603
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempshield,f))
19604 {
19605 return qe_invalid;
19606 }
19607
19608
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempwallet,f))
19609 {
19610 return qe_invalid;
19611 }
19612
19613
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbracelet,f))
19614 {
19615 return qe_invalid;
19616 }
19617
19618
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempamulet,f))
19619 {
19620 return qe_invalid;
19621 }
19622
19623
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbow,f))
19624 {
19625 return qe_invalid;
19626 }
19627
19628 //old only
19629
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build<174))
19630 {
19631 tempring=(tempring)?(1<<(tempring-1)):0;
19632 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19633 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19634 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19635 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19636 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19637 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19638 }
19639
19640 //rings start at level 2... wtf
19641 //account for this -DD
19642 12 tempring <<= 1;
19643
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19644
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19645
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19646
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19647 //bracelet ALSO starts at level 2 :-( -DD
19648 12 tempbracelet<<=1;
19649
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19650
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19651
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19652
19653 //new only
19654
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build>173))
19655 {
19656 for(int32_t q=0; q<32; q++)
19657 {
19658 if(!p_getc(&padding,f))
19659 {
19660 return qe_invalid;
19661 }
19662 }
19663 }
19664
19665 char tempcandle, tempboomerang, temparrow, tempwhistle;
19666
19667
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempcandle,f))
19668 {
19669 return qe_invalid;
19670 }
19671
19672
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempboomerang,f))
19673 {
19674 return qe_invalid;
19675 }
19676
19677
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temparrow,f))
19678 {
19679 return qe_invalid;
19680 }
19681
19682
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19683 {
19684 return qe_invalid;
19685 }
19686
19687
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19688
19689
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempwhistle,f))
19690 {
19691 return qe_invalid;
19692 }
19693
19694 //old only
19695
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build<174))
19696 {
19697 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19698 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19699 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19700 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19701 }
19702
19703
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19704
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19705
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19706
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19707 //What about the potion...?
19708
19709 12 }
19710
19711
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 89 times.
178 if(s_version < 29)
19712 {
19713 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19714 //to jab out my eye...
19715
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19716 return qe_invalid;
19717 89 temp_zinit.bombs = padding;
19718
19719
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19720 return qe_invalid;
19721 89 temp_zinit.super_bombs = padding;
19722 89 }
19723
19724 //Back to more OLD item code
19725
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
178 if(s_version < 10)
19726 {
19727
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version > 0x192)||
19728 //new only
19729 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19730 {
19731
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19732 {
19733 return qe_invalid;
19734 }
19735
19736
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19737
19738
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19739 {
19740 return qe_invalid;
19741 }
19742
19743
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19744
19745
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19746 {
19747 return qe_invalid;
19748 }
19749
19750
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19751
19752
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19753 {
19754 return qe_invalid;
19755 }
19756
19757
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19758
19759
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19760 {
19761 return qe_invalid;
19762 }
19763
19764
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19765
19766
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19767 {
19768 return qe_invalid;
19769 }
19770
19771
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19772
19773
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19774 {
19775 return qe_invalid;
19776 }
19777
19778
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19779
19780
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19781 {
19782 return qe_invalid;
19783 }
19784
19785
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19786
19787
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19788 {
19789 return qe_invalid;
19790 }
19791
19792
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19793
19794
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19795 {
19796 return qe_invalid;
19797 }
19798
19799
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(Header->zelda_version == 0x192)
19800 {
19801 for(int32_t q=0; q<32; q++)
19802 {
19803 if(!p_getc(&padding,f))
19804 {
19805 return qe_invalid;
19806 }
19807 }
19808 }
19809 12 }
19810 12 }
19811
19812 //old only
19813
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
24 if((Header->zelda_version == 0x192)&&(Header->build<174))
19814 {
19815 byte equipment, items; //bit flags
19816
19817 if(!p_getc(&equipment,f))
19818 {
19819 return qe_invalid;
19820 }
19821
19822 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
19823 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
19824 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
19825 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
19826 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
19827 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
19828
19829
19830 if(!p_getc(&items,f))
19831 {
19832 return qe_invalid;
19833 }
19834
19835 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
19836 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
19837 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
19838 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
19839 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
19840 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
19841 }
19842
19843 if(!p_getc(&temp_zinit.hc,f))
19844 {
19845 return qe_invalid;
19846 }
19847
19848
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 107 times.
119 if(s_version < 14)
19849 {
19850 byte temphp;
19851
19852
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temphp,f))
19853 {
19854 return qe_invalid;
19855 }
19856
19857 12 temp_zinit.start_heart=temphp;
19858
19859
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temphp,f))
19860 {
19861 return qe_invalid;
19862 }
19863
19864 12 temp_zinit.cont_heart=temphp;
19865 12 }
19866 else
19867 {
19868
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_igetw(&temp_zinit.start_heart,f))
19869 {
19870 return qe_invalid;
19871 }
19872
19873
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_igetw(&temp_zinit.cont_heart,f))
19874 {
19875 return qe_invalid;
19876 }
19877 }
19878
19879
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!p_getc(&temp_zinit.hcp,f))
19880 {
19881 return qe_invalid;
19882 }
19883
19884
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 12 times.
119 if(s_version >= 14)
19885 {
19886
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_getc(&temp_zinit.hcp_per_hc,f))
19887 {
19888 return qe_invalid;
19889 }
19890
19891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(s_version<16) // July 2007
19892 {
19893 if(get_qr(qr_BRANGPICKUP+1))
19894 temp_zinit.hcp_per_hc = 0xFF;
19895
19896 //Dispose of legacy rule
19897 set_qr(qr_BRANGPICKUP+1, 0);
19898 }
19899 107 }
19900
19901
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 30 times.
119 if(s_version < 29)
19902 {
19903
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19904 return qe_invalid;
19905 89 temp_zinit.max_bombs = padding;
19906 89 }
19907
19908
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!p_getc(&temp_zinit.keys,f))
19909 {
19910 return qe_invalid;
19911 }
19912
19913
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!p_igetw(&temp_zinit.rupies,f))
19914 {
19915 return qe_invalid;
19916 }
19917
19918
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!p_getc(&temp_zinit.triforce,f))
19919 {
19920 return qe_invalid;
19921 }
19922
19923
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 107 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
119 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19924 {
19925
2/2
✓ Branch 0 taken 6848 times.
✓ Branch 1 taken 107 times.
6955 for(int32_t i=0; i<64; i++)
19926 {
19927
2/4
✓ Branch 0 taken 6848 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6848 times.
6848 if(!p_getc(&temp_zinit.map[i],f))
19928 {
19929 return qe_invalid;
19930 }
19931 6848 }
19932
19933
2/2
✓ Branch 0 taken 6848 times.
✓ Branch 1 taken 107 times.
6955 for(int32_t i=0; i<64; i++)
19934 {
19935
2/4
✓ Branch 0 taken 6848 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6848 times.
6848 if(!p_getc(&temp_zinit.compass[i],f))
19936 {
19937 return qe_invalid;
19938 }
19939 6848 }
19940 107 }
19941 else
19942 {
19943
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19944 {
19945
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
384 if(!p_getc(&temp_zinit.map[i],f))
19946 {
19947 return qe_invalid;
19948 }
19949 384 }
19950
19951
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19952 {
19953
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
384 if(!p_getc(&temp_zinit.compass[i],f))
19954 {
19955 return qe_invalid;
19956 }
19957 384 }
19958 }
19959
19960
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
119 if((Header->zelda_version > 0x192)||
19961 //new only
19962 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19963 {
19964
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 107 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
119 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19965 {
19966
2/2
✓ Branch 0 taken 6848 times.
✓ Branch 1 taken 107 times.
6955 for(int32_t i=0; i<64; i++)
19967 {
19968
2/4
✓ Branch 0 taken 6848 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6848 times.
6848 if(!p_getc(&temp_zinit.boss_key[i],f))
19969 {
19970 return qe_invalid;
19971 }
19972 6848 }
19973 107 }
19974 else
19975 {
19976
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19977 {
19978
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 384 times.
✗ Branch 3 not taken.
384 if(!p_getc(&temp_zinit.boss_key[i],f))
19979 {
19980 return qe_invalid;
19981 }
19982 384 }
19983 }
19984 119 }
19985
19986
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 1904 times.
2023 for(int32_t i=0; i<16; i++)
19987 {
19988
2/4
✓ Branch 0 taken 1904 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1904 times.
1904 if(!p_getc(&temp_zinit.misc[i],f))
19989 {
19990 return qe_invalid;
19991 }
19992 1904 }
19993
19994
4/4
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 12 times.
167 if(s_version < 15) for(int32_t i=0; i<4; i++)
19995 {
19996
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
48 if(!p_getc(&sword_hearts[i],f))
19997 {
19998 return qe_invalid;
19999 }
20000 60 }
20001
20002
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!p_getc(&temp_zinit.last_map,f))
20003 {
20004 return qe_invalid;
20005 }
20006
20007
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!p_getc(&temp_zinit.last_screen,f))
20008 {
20009 return qe_invalid;
20010 }
20011
20012
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 107 times.
119 if(s_version < 14)
20013 {
20014 byte tempmp;
20015
20016
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempmp,f))
20017 {
20018 return qe_invalid;
20019 }
20020
20021 12 temp_zinit.max_magic=tempmp;
20022
20023
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempmp,f))
20024 {
20025 return qe_invalid;
20026 }
20027
20028 12 temp_zinit.magic=tempmp;
20029 12 }
20030 else
20031 {
20032
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_igetw(&temp_zinit.max_magic,f))
20033 {
20034 return qe_invalid;
20035 }
20036
20037
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_igetw(&temp_zinit.magic,f))
20038 {
20039 return qe_invalid;
20040 }
20041 }
20042
20043
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 12 times.
119 if(s_version < 15)
20044 {
20045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(s_version < 12)
20046 {
20047 12 temp_zinit.max_magic*=32;
20048 12 temp_zinit.magic*=32;
20049 12 }
20050
20051
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 48 times.
60 for(int32_t i=0; i<4; i++)
20052 {
20053
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
48 if(!p_getc(&beam_hearts[i],f))
20054 {
20055 return qe_invalid;
20056 }
20057 48 }
20058
20059
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&beam_percent,f))
20060 {
20061 return qe_invalid;
20062 }
20063 12 }
20064 else
20065 {
20066
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_getc(&temp_zinit.bomb_ratio,f))
20067 {
20068 return qe_invalid;
20069 }
20070 }
20071
20072
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 12 times.
119 if(s_version < 15)
20073 {
20074 byte tempbp;
20075
20076
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 48 times.
60 for(int32_t i=0; i<4; i++)
20077 {
20078
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
48 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
20079 {
20080 return qe_invalid;
20081 }
20082
20083 48 beam_power[i]=tempbp;
20084 48 }
20085
20086
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&hookshot_links,f))
20087 {
20088 return qe_invalid;
20089 }
20090
20091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(s_version>6)
20092 {
20093 if(!p_getc(&hookshot_length,f))
20094 {
20095 return qe_invalid;
20096 }
20097
20098 if(!p_getc(&longshot_links,f))
20099 {
20100 return qe_invalid;
20101 }
20102
20103 if(!p_getc(&longshot_length,f))
20104 {
20105 return qe_invalid;
20106 }
20107 }
20108 12 }
20109
20110
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!p_getc(&temp_zinit.msg_more_x,f))
20111 {
20112 return qe_invalid;
20113 }
20114
20115
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!p_getc(&temp_zinit.msg_more_y,f))
20116 {
20117 return qe_invalid;
20118 }
20119
20120
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!p_getc(&temp_zinit.subscreen,f))
20121 {
20122 return qe_invalid;
20123 }
20124
20125 //old only
20126
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
119 if((Header->zelda_version == 0x192)&&(Header->build<174))
20127 {
20128 for(int32_t i=0; i<32; i++)
20129 {
20130 if(!p_getc(&temp_zinit.boss_key[i],f))
20131 {
20132 return qe_invalid;
20133 }
20134 }
20135 }
20136
20137
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
119 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20138 {
20139
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 107 times.
119 if(s_version <= 10)
20140 {
20141 byte tempbyte;
20142
20143
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbyte,f))
20144 {
20145 return qe_invalid;
20146 }
20147
20148 12 temp_zinit.start_dmap = (word)tempbyte;
20149 12 }
20150 else
20151 {
20152
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_igetw(&temp_zinit.start_dmap,f))
20153 {
20154 return qe_invalid;
20155 }
20156 }
20157
20158
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20159 {
20160 return qe_invalid;
20161 }
20162 119 }
20163
20164
4/4
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 30 times.
119 if(s_version>1 && s_version < 29)
20165 {
20166
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f))
20167 return qe_invalid;
20168 77 temp_zinit.arrows = padding;
20169
20170
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f))
20171 return qe_invalid;
20172 77 temp_zinit.max_arrows = padding;
20173 77 }
20174
20175
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 107 times.
119 if(s_version>2)
20176 {
20177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(s_version <= 10)
20178 {
20179 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20180 {
20181 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20182 {
20183 return qe_invalid;
20184 }
20185 }
20186 }
20187 else
20188 {
20189
2/2
✓ Branch 0 taken 54784 times.
✓ Branch 1 taken 107 times.
54891 for(int32_t i=0; i<MAXLEVELS; i++)
20190 {
20191
2/4
✓ Branch 0 taken 54784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54784 times.
✗ Branch 3 not taken.
54784 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20192 {
20193 return qe_invalid;
20194 }
20195 54784 }
20196 }
20197 107 }
20198
20199
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 12 times.
119 if(s_version>3)
20200 {
20201
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_igetw(&temp_zinit.ss_grid_x,f))
20202 {
20203 return qe_invalid;
20204 }
20205
20206
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_igetw(&temp_zinit.ss_grid_y,f))
20207 {
20208 return qe_invalid;
20209 }
20210
20211
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
20212 {
20213 return qe_invalid;
20214 }
20215
20216
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
20217 {
20218 return qe_invalid;
20219 }
20220
20221
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20222 {
20223 return qe_invalid;
20224 }
20225
20226
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20227 {
20228 return qe_invalid;
20229 }
20230
20231
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20232 {
20233 return qe_invalid;
20234 }
20235
20236
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_igetw(&temp_zinit.ss_flags,f))
20237 {
20238 return qe_invalid;
20239 }
20240
20241
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20242
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20243 107 }
20244
20245
3/4
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 107 times.
119 if(s_version>4 && s_version<15)
20246 {
20247 if(!p_getc(&moving_fairy_hearts,f))
20248 {
20249 return qe_invalid;
20250 }
20251
20252 if(!p_getc(&moving_fairy_heart_percent,f))
20253 {
20254 return qe_invalid;
20255 }
20256 }
20257
20258
3/4
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 107 times.
119 if(s_version>5 && s_version < 10)
20259 {
20260 if(!p_getc(&temp,f))
20261 {
20262 return qe_invalid;
20263 }
20264
20265 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20266 }
20267
20268
3/4
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 107 times.
119 if(s_version>6 && s_version<15)
20269 {
20270 if(!p_getc(&stationary_fairy_hearts,f))
20271 {
20272 return qe_invalid;
20273 }
20274
20275 if(!p_getc(&stationary_fairy_heart_percent,f))
20276 {
20277 return qe_invalid;
20278 }
20279
20280 if(!p_getc(&moving_fairy_magic,f))
20281 {
20282 return qe_invalid;
20283 }
20284
20285 if(!p_getc(&moving_fairy_magic_percent,f))
20286 {
20287 return qe_invalid;
20288 }
20289
20290 if(!p_getc(&stationary_fairy_magic,f))
20291 {
20292 return qe_invalid;
20293 }
20294
20295 if(!p_getc(&stationary_fairy_magic_percent,f))
20296 {
20297 return qe_invalid;
20298 }
20299
20300 if(!p_getc(&blue_potion_hearts,f))
20301 {
20302 return qe_invalid;
20303 }
20304
20305 if(!p_getc(&blue_potion_heart_percent,f))
20306 {
20307 return qe_invalid;
20308 }
20309
20310 if(!p_getc(&red_potion_hearts,f))
20311 {
20312 return qe_invalid;
20313 }
20314
20315 if(!p_getc(&red_potion_heart_percent,f))
20316 {
20317 return qe_invalid;
20318 }
20319
20320 if(!p_getc(&blue_potion_magic,f))
20321 {
20322 return qe_invalid;
20323 }
20324
20325 if(!p_getc(&blue_potion_magic_percent,f))
20326 {
20327 return qe_invalid;
20328 }
20329
20330 if(!p_getc(&red_potion_magic,f))
20331 {
20332 return qe_invalid;
20333 }
20334
20335 if(!p_getc(&red_potion_magic_percent,f))
20336 {
20337 return qe_invalid;
20338 }
20339 }
20340
20341
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 12 times.
119 if(s_version>6)
20342 {
20343
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_getc(&temp_zinit.subscreen_style,f))
20344 {
20345 return qe_invalid;
20346 }
20347 107 }
20348
20349
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 12 times.
119 if(s_version>7)
20350 {
20351
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_getc(&temp_zinit.usecustomsfx,f))
20352 {
20353 return qe_invalid;
20354 }
20355 107 }
20356
20357
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 12 times.
119 if(s_version>8)
20358 {
20359
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_igetw(&temp_zinit.max_rupees,f))
20360 {
20361 return qe_invalid;
20362 }
20363
20364
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_igetw(&temp_zinit.max_keys,f))
20365 {
20366 return qe_invalid;
20367 }
20368 107 }
20369
20370
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 12 times.
119 if(s_version>16)
20371 {
20372
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_getc(&temp_zinit.gravity,f))
20373 {
20374 return qe_invalid;
20375 }
20376
20377
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_igetw(&temp_zinit.terminalv,f))
20378 {
20379 return qe_invalid;
20380 }
20381
20382
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_getc(&temp_zinit.msg_speed,f))
20383 {
20384 return qe_invalid;
20385 }
20386
20387
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_getc(&temp_zinit.transition_type,f))
20388 {
20389 return qe_invalid;
20390 }
20391
20392
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20393 {
20394 return qe_invalid;
20395 }
20396 107 }
20397
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 else if (replay_version_check(0, 13))
20398 12 temp_zinit.msg_speed = 0;
20399
20400
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 12 times.
119 if(s_version>17)
20401 {
20402
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20403 {
20404 return qe_invalid;
20405 }
20406 107 }
20407
20408 //expaned init data for larger values in 2.55
20409
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 89 times.
119 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20410 {
20411
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.bombs,f))
20412 {
20413 return qe_invalid;
20414 }
20415
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.super_bombs,f))
20416 {
20417 return qe_invalid;
20418 }
20419
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.max_bombs,f))
20420 {
20421 return qe_invalid;
20422 }
20423
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.max_sbombs,f))
20424 {
20425 return qe_invalid;
20426 }
20427
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.arrows,f))
20428 {
20429 return qe_invalid;
20430 }
20431
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.max_arrows,f))
20432 {
20433 return qe_invalid;
20434 }
20435
20436 30 }
20437
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 89 times.
119 if ( s_version >= 20 )
20438 {
20439
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.heroStep,f))
20440 {
20441 return qe_invalid;
20442 }
20443 30 }
20444 else
20445 {
20446 89 temp_zinit.heroStep = 150; //1.5 pixels per frame
20447 }
20448
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 89 times.
119 if ( s_version >= 21 )
20449 {
20450
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20451 {
20452 return qe_invalid;
20453 }
20454 30 }
20455 else
20456 {
20457 89 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20458 }
20459 //old only
20460
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
119 if((Header->zelda_version == 0x192)&&(Header->build<174))
20461 {
20462 byte items2;
20463
20464 if(!p_getc(&items2,f))
20465 {
20466 return qe_invalid;
20467 }
20468
20469 temp_zinit.items[iDivineFire]=(get_bit(&items2, idI_DFIRE)!=0);
20470 temp_zinit.items[iDivineEscape]=(get_bit(&items2, idI_FWIND)!=0);
20471 temp_zinit.items[iDivineProtection]=(get_bit(&items2, idI_NLOVE)!=0);
20472 }
20473
20474
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(Header->zelda_version < 0x193)
20475 {
20476 for(int32_t q=0; q<96; q++)
20477 {
20478 if(!p_getc(&padding,f))
20479 {
20480 return qe_invalid;
20481 }
20482 }
20483
20484 //new only
20485 if((Header->zelda_version == 0x192)&&(Header->build>173))
20486 {
20487 if(!p_getc(&padding,f))
20488 {
20489 return qe_invalid;
20490 }
20491
20492 if(!p_getc(&padding,f))
20493 {
20494 return qe_invalid;
20495 }
20496 }
20497 }
20498 119 }
20499
20500
3/6
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 107 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
182 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20501 {
20502 //temp_zinit.shield=i_smallshield;
20503
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 59 times.
75 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20504
20505
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(sshieldid != -1)
20506 16 temp_zinit.items[sshieldid] = true;
20507 16 }
20508
20509
3/6
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
123 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20510 {
20511 4 temp_zinit.hc=3;
20512 4 temp_zinit.start_heart=3;
20513 4 temp_zinit.cont_heart=3;
20514 4 temp_zinit.max_bombs=8;
20515 4 }
20516
20517
3/6
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
123 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20518 {
20519 4 sword_hearts[0]=0;
20520 4 sword_hearts[1]=5;
20521 4 sword_hearts[2]=12;
20522 4 sword_hearts[3]=21;
20523 4 }
20524
20525
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
123 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20526 {
20527 4 temp_zinit.last_map=0;
20528 4 temp_zinit.last_screen=0;
20529 4 }
20530
20531
3/6
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
123 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20532 {
20533 4 temp_zinit.max_magic=0;
20534 4 temp_zinit.magic=0;
20535
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20536 4 }
20537
20538
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
123 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20539 {
20540
20541
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t x=0; x<4; x++)
20542 {
20543 16 beam_hearts[x]=100;
20544 16 }
20545
20546
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<idBP_MAX; i++)
20547 {
20548
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20549
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 set_qr(qr_LENSHINTS+i,0);
20550 16 }
20551
20552
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
20 for(int32_t x=0; x<4; x++)
20553 {
20554
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20555 16 }
20556
20557
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_HIDECARRIEDITEMS,0);
20558 4 hookshot_links=100;
20559 4 temp_zinit.msg_more_x=224;
20560 4 temp_zinit.msg_more_y=64;
20561 4 }
20562
20563 // Okay, let's put these legacy values into itemsbuf.
20564
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if(s_version < 15)
20565
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4096 times.
4112 for(int32_t i=0; i<MAXITEMS; i++)
20566 {
20567
11/11
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 8 taken 3936 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
4096 switch(i)
20568 {
20569 case iFairyStill:
20570 16 itemsbuf[i].misc1 = stationary_fairy_hearts;
20571 16 itemsbuf[i].misc2 = stationary_fairy_magic;
20572 16 itemsbuf[i].misc3 = 0;
20573 16 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20574 16 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20575 16 break;
20576
20577 case iFairyMoving:
20578 16 itemsbuf[i].misc1 = moving_fairy_hearts;
20579 16 itemsbuf[i].misc2 = moving_fairy_magic;
20580 16 itemsbuf[i].misc3 = 50;
20581 16 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20582 16 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20583 16 break;
20584
20585 case iRPotion:
20586 16 itemsbuf[i].misc1 = red_potion_hearts;
20587 16 itemsbuf[i].misc2 = red_potion_magic;
20588 16 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20589 16 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20590 16 break;
20591
20592 case iBPotion:
20593 16 itemsbuf[i].misc1 = blue_potion_hearts;
20594 16 itemsbuf[i].misc2 = blue_potion_magic;
20595 16 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20596 16 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20597 16 break;
20598
20599 case iSword:
20600 16 itemsbuf[i].pickup_hearts = sword_hearts[0];
20601 16 itemsbuf[i].misc1 = beam_hearts[0];
20602 16 itemsbuf[i].misc2 = beam_power[0];
20603 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20604
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20605 16 break;
20606
20607 case iWSword:
20608 16 itemsbuf[i].pickup_hearts = sword_hearts[1];
20609 16 itemsbuf[i].misc1 = beam_hearts[1];
20610 16 itemsbuf[i].misc2 = beam_power[1];
20611
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20612 16 break;
20613
20614 case iMSword:
20615 16 itemsbuf[i].pickup_hearts = sword_hearts[2];
20616 16 itemsbuf[i].misc1 = beam_hearts[2];
20617 16 itemsbuf[i].misc2 = beam_power[2];
20618
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20619 16 break;
20620
20621 case iXSword:
20622 16 itemsbuf[i].pickup_hearts = sword_hearts[3];
20623 16 itemsbuf[i].misc1 = beam_hearts[3];
20624 16 itemsbuf[i].misc2 = beam_power[3];
20625
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20626 16 break;
20627
20628 case iHookshot:
20629 16 itemsbuf[i].misc1 = hookshot_length;
20630 16 itemsbuf[i].misc2 = hookshot_links;
20631 16 break;
20632
20633 case iLongshot:
20634 16 itemsbuf[i].misc1 = longshot_length;
20635 16 itemsbuf[i].misc2 = longshot_links;
20636 16 break;
20637 }
20638 4112 }
20639
20640
3/6
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
123 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20641 {
20642 //was new subscreen rule
20643
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.subscreen=get_qr(qr_FREEFORM)?1:0;
20644
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_FREEFORM,0);
20645 4 }
20646
20647
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
123 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20648 {
20649 4 temp_zinit.start_dmap=0;
20650 4 }
20651
20652
3/6
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
123 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20653 {
20654
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20655 4 }
20656
20657
4/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 107 times.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
123 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20658 {
20659 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20660 temp_zinit.max_rupees=999;
20661 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20662 }
20663
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20664 {
20665 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20666 temp_zinit.max_bombs = 8;
20667 }
20668 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20669 //time to ensure that we port all new values properly:
20670
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 16 times.
123 if(Header->zelda_version < 0x250)
20671 {
20672
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20673 16 }
20674
20675
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(s_version > 21)
20676 {
20677
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.hp_per_heart,f))
20678 {
20679 return qe_invalid;
20680 }
20681
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.magic_per_block,f))
20682 {
20683 return qe_invalid;
20684 }
20685
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20686 {
20687 return qe_invalid;
20688 }
20689
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20690 {
20691 return qe_invalid;
20692 }
20693 30 }
20694 else
20695 {
20696 93 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20697 93 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20698 93 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20699 93 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20700 }
20701
20702
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(s_version > 22)
20703 {
20704
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 30 times.
780 for(int32_t q = 0; q < 25; ++q)
20705 {
20706
2/4
✓ Branch 0 taken 750 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 750 times.
750 if(!p_igetw(&temp_zinit.scrcnt[q],f))
20707 {
20708 return qe_invalid;
20709 }
20710 750 }
20711
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 30 times.
780 for(int32_t q = 0; q < 25; ++q)
20712 {
20713
2/4
✓ Branch 0 taken 750 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 750 times.
750 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f))
20714 {
20715 return qe_invalid;
20716 }
20717 750 }
20718 30 }
20719 else
20720 {
20721
2/2
✓ Branch 0 taken 2325 times.
✓ Branch 1 taken 93 times.
2418 for(int32_t q = 0; q < 25; ++q)
20722 {
20723 2325 temp_zinit.scrcnt[q] = 0;
20724 2325 temp_zinit.scrmaxcnt[q] = 0;
20725 2325 }
20726 }
20727
20728
20729
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(s_version > 23)
20730 {
20731
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.dither_type,f))
20732 {
20733 return qe_invalid;
20734 }
20735
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.dither_arg,f))
20736 {
20737 return qe_invalid;
20738 }
20739
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.dither_percent,f))
20740 {
20741 return qe_invalid;
20742 }
20743
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.def_lightrad,f))
20744 {
20745 return qe_invalid;
20746 }
20747
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.transdark_percent,f))
20748 {
20749 return qe_invalid;
20750 }
20751 30 }
20752 else
20753 {
20754 93 temp_zinit.dither_type = 0;
20755 93 temp_zinit.dither_arg = 0;
20756 93 temp_zinit.dither_percent = 20;
20757 93 temp_zinit.def_lightrad = 24;
20758 93 temp_zinit.transdark_percent = 0;
20759 }
20760
20761
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(s_version > 24)
20762 {
20763
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.darkcol,f))
20764 {
20765 return qe_invalid;
20766 }
20767 30 }
20768 else
20769 {
20770 93 temp_zinit.darkcol = BLACK;
20771 }
20772
20773
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(s_version > 25)
20774 {
20775
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetl(&temp_zinit.gravity2,f))
20776 {
20777 return qe_invalid;
20778 }
20779
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetl(&temp_zinit.swimgravity,f))
20780 {
20781 return qe_invalid;
20782 }
20783 30 }
20784 else
20785 {
20786 93 temp_zinit.gravity2 = temp_zinit.gravity*100;
20787 93 temp_zinit.swimgravity = 5;
20788 }
20789
20790
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(s_version > 26)
20791 {
20792
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20793 {
20794 return qe_invalid;
20795 }
20796
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20797 {
20798 return qe_invalid;
20799 }
20800
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20801 {
20802 return qe_invalid;
20803 }
20804 30 }
20805 else
20806 {
20807 93 temp_zinit.heroSideswimUpStep = 150;
20808 93 temp_zinit.heroSideswimSideStep = 100;
20809 93 temp_zinit.heroSideswimDownStep = 75;
20810 }
20811
20812
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(s_version > 27)
20813 {
20814
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20815 {
20816 return qe_invalid;
20817 }
20818 30 }
20819 else
20820 {
20821 93 temp_zinit.exitWaterJump = 0;
20822 }
20823
20824
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(s_version > 29)
20825 {
20826
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20827 {
20828 return qe_invalid;
20829 }
20830 30 }
20831 else
20832 {
20833 93 temp_zinit.bunny_ltm = 0;
20834 }
20835
20836
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(s_version > 30)
20837 {
20838
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.switchhookstyle,f))
20839 {
20840 return qe_invalid;
20841 }
20842 30 }
20843 else
20844 {
20845 93 temp_zinit.switchhookstyle = 1;
20846 }
20847
20848
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
123 if(s_version > 31)
20849 {
20850
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.magicdrainrate,f))
20851 {
20852 return qe_invalid;
20853 }
20854 30 }
20855 else
20856 {
20857
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
20858
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20859 }
20860
20861
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 temp_zinit.clear_genscript();
20862
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 95 times.
123 if(s_version > 32)
20863 {
20864 28 word numgenscript = 0;
20865
2/4
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
28 if(!p_igetw(&numgenscript,f))
20866 return qe_invalid;
20867
2/4
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
28 if (!(numgenscript >= 0 && numgenscript <= NUMSCRIPTSGENERIC))
20868 return qe_invalid;
20869
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 for(auto q = 1; q < numgenscript; ++q)
20870 {
20871 if(!p_getc(&padding,f))
20872 return qe_invalid;
20873 if(!(padding&2))
20874 continue;
20875 temp_zinit.gen_doscript[q] = padding&1;
20876 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
20877 return qe_invalid;
20878 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
20879 return qe_invalid;
20880 for(auto p = 0; p < 8; ++p)
20881 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
20882 return qe_invalid;
20883 if(!p_igetl(&temp_zinit.gen_dataSize[q],f))
20884 return qe_invalid;
20885 if(!p_getlvec<int32_t>(&temp_zinit.gen_data[q],f))
20886 return qe_invalid;
20887 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
20888 return qe_invalid;
20889 }
20890 28 }
20891
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 98 times.
123 if(s_version > 33)
20892 {
20893
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20894 return qe_invalid;
20895
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_getc(&temp_zinit.hero_swim_div,f))
20896 return qe_invalid;
20897 25 }
20898
20899
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 zinit = temp_zinit;
20900
20901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(zinit.heroAnimationStyle==las_zelda3slow)
20902 {
20903 hero_animation_speed=2;
20904 }
20905 else
20906 {
20907 123 hero_animation_speed=1;
20908 }
20909
20910 123 return 0;
20911 479 }
20912
20913 /*
20914 void setupitemdropsets()
20915 {
20916 for(int32_t i=0; i<isMAX; i++)
20917 {
20918 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
20919 }
20920 }
20921 */
20922
20923 111 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build)
20924 {
20925 111 build=build; // here to prevent compiler warnings
20926 dword dummy_dword;
20927 111 word item_drop_sets_to_read=0;
20928 item_drop_object tempitemdrop;
20929 111 word s_version=0, s_cversion=0;
20930
20931
2/2
✓ Branch 0 taken 28416 times.
✓ Branch 1 taken 111 times.
28527 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
20932 {
20933 28416 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
20934 28416 }
20935
20936
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 4 times.
111 if(version > 0x192)
20937 {
20938 107 item_drop_sets_to_read=0;
20939
20940 //section version info
20941
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetw(&s_version,f))
20942 {
20943 return qe_invalid;
20944 }
20945
20946 107 FFCore.quest_format[vItemDropsets] = s_version;
20947
20948 //al_trace("Item drop sets version %d\n", s_version);
20949
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetw(&s_cversion,f))
20950 {
20951 return qe_invalid;
20952 }
20953
20954 //section size
20955
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetl(&dummy_dword,f))
20956 {
20957 return qe_invalid;
20958 }
20959
20960 //finally... section data
20961
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetw(&item_drop_sets_to_read,f))
20962 {
20963 return qe_invalid;
20964 }
20965
20966
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
107 if (!(item_drop_sets_to_read >= 0 && item_drop_sets_to_read <= MAXITEMDROPSETS))
20967 {
20968 return qe_invalid;
20969 }
20970 107 }
20971 else
20972 {
20973 4 init_item_drop_sets();
20974 }
20975
20976
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 107 times.
111 if(s_version>=1)
20977 {
20978
2/2
✓ Branch 0 taken 1991 times.
✓ Branch 1 taken 107 times.
2098 for(int32_t i=0; i<item_drop_sets_to_read; i++)
20979 {
20980
1/2
✓ Branch 0 taken 1991 times.
✗ Branch 1 not taken.
1991 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f))
20981 {
20982 return qe_invalid;
20983 }
20984
20985
2/2
✓ Branch 0 taken 19910 times.
✓ Branch 1 taken 1991 times.
21901 for(int32_t j=0; j<10; ++j)
20986 {
20987
1/2
✓ Branch 0 taken 19910 times.
✗ Branch 1 not taken.
19910 if(!p_igetw(&tempitemdrop.item[j],f))
20988 {
20989 return qe_invalid;
20990 }
20991 19910 }
20992
20993
2/2
✓ Branch 0 taken 21901 times.
✓ Branch 1 taken 1991 times.
23892 for(int32_t j=0; j<11; ++j)
20994 {
20995
1/2
✓ Branch 0 taken 21901 times.
✗ Branch 1 not taken.
21901 if(!p_igetw(&tempitemdrop.chance[j],f))
20996 {
20997 return qe_invalid;
20998 }
20999 21901 }
21000
21001 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21002 // overrides the quest's set #12.
21003
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1991 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1991 if(s_version<2 && i==12)
21004 continue;
21005
21006 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21007
1/4
✓ Branch 0 taken 1991 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1991 if(s_version<2) for(int32_t j=0; j<10; ++j)
21008 {
21009 int32_t it = tempitemdrop.item[j];
21010
21011 if((itemsbuf[it].family == itype_rupee
21012 && ((itemsbuf[it].amount)&0xFFF) == 10)
21013 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21014 {
21015 tempitemdrop.chance[j+1]=0;
21016 }
21017 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21018 {
21019 tempitemdrop.chance[j+1]=0;
21020 }
21021
21022 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21023 if(itemsbuf[it].family == itype_misc)
21024 {
21025 // If a non-gameplay item was selected, then item drop was aborted.
21026 // Reflect this by increasing the 'Nothing' chance accordingly.
21027 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21028 tempitemdrop.chance[j+1]=0;
21029 }
21030 }
21031
21032 1991 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21033 1991 }
21034 107 }
21035
21036 111 return 0;
21037 111 }
21038
21039 107 int32_t readfavorites(PACKFILE *f, int32_t, word)
21040 {
21041 int32_t temp_num;
21042 dword dummy_dword;
21043 word num_favorite_combos;
21044 word num_favorite_combo_aliases;
21045 107 word s_version=0, s_cversion=0;
21046
21047 //section version info
21048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(!p_igetw(&s_version,f))
21049 {
21050 return qe_invalid;
21051 }
21052
21053 107 FFCore.quest_format[vFavourites] = s_version;
21054
21055
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetw(&s_cversion,f))
21056 {
21057 return qe_invalid;
21058 }
21059
21060 //section size
21061
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetl(&dummy_dword,f))
21062 {
21063 return qe_invalid;
21064 }
21065
21066 107 word per_row = FAVORITECOMBO_PER_ROW;
21067
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 25 times.
107 if(s_version >= 3)
21068
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&per_row,f))
21069 return qe_invalid;
21070 //finally... section data
21071
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetw(&num_favorite_combos,f))
21072 {
21073 return qe_invalid;
21074 }
21075
21076 //Hack; port old favorite combos
21077
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 82 times.
107 if(s_version < 3 && num_favorite_combos == 100)
21078 82 per_row = 13;
21079
21080
2/2
✓ Branch 0 taken 32100 times.
✓ Branch 1 taken 107 times.
32207 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21081 32100 favorite_combos[q] = -1;
21082
2/2
✓ Branch 0 taken 32100 times.
✓ Branch 1 taken 107 times.
32207 for(int q = 0; q < MAXFAVORITECOMBOALIASES; ++q)
21083 32100 favorite_comboaliases[q] = -1;
21084
2/2
✓ Branch 0 taken 8729 times.
✓ Branch 1 taken 107 times.
8836 for(int32_t i=0; i<num_favorite_combos; i++)
21085 {
21086
1/2
✓ Branch 0 taken 8729 times.
✗ Branch 1 not taken.
8729 if(!p_igetl(&temp_num,f))
21087 {
21088 return qe_invalid;
21089 }
21090
21091
2/2
✓ Branch 0 taken 529 times.
✓ Branch 1 taken 8200 times.
8729 if(per_row == FAVORITECOMBO_PER_ROW)
21092 529 favorite_combos[i]=temp_num;
21093 else
21094 {
21095 8200 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21096 8200 favorite_combos[new_i]=temp_num;
21097 }
21098 8729 }
21099
21100
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetw(&num_favorite_combo_aliases,f))
21101 {
21102 return qe_invalid;
21103 }
21104
21105
2/2
✓ Branch 0 taken 8200 times.
✓ Branch 1 taken 107 times.
8307 for(int32_t i=0; i<num_favorite_combo_aliases; i++)
21106 {
21107
1/2
✓ Branch 0 taken 8200 times.
✗ Branch 1 not taken.
8200 if(!p_igetl(&temp_num,f))
21108 {
21109 return qe_invalid;
21110 }
21111
21112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8200 times.
8200 if(per_row == FAVORITECOMBO_PER_ROW)
21113 favorite_comboaliases[i]=temp_num;
21114 else
21115 {
21116 8200 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21117 8200 favorite_comboaliases[new_i]=temp_num;
21118 }
21119 8200 }
21120
21121 107 word max_combo_cols = 0;
21122 107 word max_mappages = 0;
21123
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 25 times.
107 if(s_version >= 2)
21124 {
21125
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&max_combo_cols,f))
21126 return qe_invalid;
21127 25 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21128
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int q = 0; q < max_combo_cols; ++q)
21129 {
21130
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tmp,f))
21131 return qe_invalid;
21132
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tmp2,f))
21133 return qe_invalid;
21134
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tmp3,f))
21135 return qe_invalid;
21136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(q < MAX_COMBO_COLS)
21137 {
21138 100 First[q] = tmp;
21139 100 combo_alistpos[q] = tmp2;
21140 100 combo_pool_listpos[q] = tmp3;
21141 100 }
21142 100 }
21143
21144
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&max_mappages,f))
21145 return qe_invalid;
21146
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 25 times.
250 for(int q = 0; q < max_mappages; ++q)
21147 {
21148
1/2
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
225 if(!p_igetl(&tmp,f))
21149 return qe_invalid;
21150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 225 times.
225 if(!p_igetl(&tmp2,f))
21151 return qe_invalid;
21152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 225 times.
225 if(q < MAX_MAPPAGE_BTNS)
21153 {
21154 225 map_page[q].map = tmp;
21155 225 map_page[q].screen = tmp2;
21156 225 }
21157 225 }
21158 25 }
21159
21160
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 107 times.
435 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21161 {
21162 328 First[q] = 0;
21163 328 combo_alistpos[q] = 0;
21164 328 combo_pool_listpos[q] = 0;
21165 328 }
21166
2/2
✓ Branch 0 taken 738 times.
✓ Branch 1 taken 107 times.
845 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21167 {
21168 738 map_page[q].map = 0;
21169 738 map_page[q].screen = 0;
21170 738 }
21171
21172 107 return 0;
21173 107 }
21174
21175 /*
21176 switch (ret) {
21177 case 0:
21178 break;
21179
21180 case qe_invalid:
21181 goto invalid;
21182 break;
21183 default:
21184 pack_fclose(f);
21185 if(!oldquest)
21186 delete_file(tmpfilename);
21187 return ret;
21188 break;
21189 }
21190 */
21191
21192 const char *skip_text[skip_max]=
21193 {
21194 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21195 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21196 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21197 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21198 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21199 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21200 "skip_favorites"
21201 };
21202
21203
21204 void port250QuestRules(){
21205
21206 portCandleRules(); //Candle
21207 portBombRules();
21208
21209 }
21210
21211 void portCandleRules()
21212 {
21213 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21214 //itemdata itemsbuf;
21215 for ( int32_t q = 0; q < MAXITEMS; q++ )
21216 {
21217 if ( itemsbuf[q].family == itype_candle )
21218 {
21219 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21220 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21221 }
21222 }
21223 }
21224
21225 void portBombRules()
21226 {
21227 bool hurtshero = get_qr(qr_OUCHBOMBS);
21228 //itemdata itemsbuf;
21229 for ( int32_t q = 0; q < MAXITEMS; q++ )
21230 {
21231 if ( itemsbuf[q].family == itype_bomb )
21232 {
21233 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21234 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21235 }
21236 }
21237 }
21238
21239 2748 static int section_id_to_enum(int id)
21240 {
21241
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 119 times.
✓ Branch 3 taken 119 times.
✓ Branch 4 taken 119 times.
✓ Branch 5 taken 119 times.
✓ Branch 6 taken 107 times.
✓ Branch 7 taken 119 times.
✓ Branch 8 taken 119 times.
✓ Branch 9 taken 119 times.
✓ Branch 10 taken 119 times.
✓ Branch 11 taken 119 times.
✓ Branch 12 taken 119 times.
✓ Branch 13 taken 107 times.
✓ Branch 14 taken 107 times.
✓ Branch 15 taken 119 times.
✓ Branch 16 taken 119 times.
✓ Branch 17 taken 107 times.
✓ Branch 18 taken 107 times.
✓ Branch 19 taken 107 times.
✓ Branch 20 taken 107 times.
✓ Branch 21 taken 119 times.
✓ Branch 22 taken 119 times.
✓ Branch 23 taken 107 times.
✓ Branch 24 taken 107 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2748 switch (id)
21242 {
21243 case ID_HEADER: return skip_header;
21244 119 case ID_RULES: return skip_rules;
21245 119 case ID_STRINGS: return skip_strings;
21246 119 case ID_MISC: return skip_misc;
21247 119 case ID_TILES: return skip_tiles;
21248 119 case ID_COMBOS: return skip_combos;
21249 107 case ID_COMBOALIASES: return skip_comboaliases;
21250 119 case ID_CSETS: return skip_csets;
21251 119 case ID_MAPS: return skip_maps;
21252 119 case ID_DMAPS: return skip_dmaps;
21253 119 case ID_DOORS: return skip_doors;
21254 119 case ID_ITEMS: return skip_items;
21255 119 case ID_WEAPONS: return skip_weapons;
21256 107 case ID_COLORS: return skip_colors;
21257 107 case ID_ICONS: return skip_icons;
21258 119 case ID_INITDATA: return skip_initdata;
21259 119 case ID_GUYS: return skip_guys;
21260 107 case ID_HEROSPRITES: return skip_herosprites;
21261 107 case ID_SUBSCREEN: return skip_subscreens;
21262 107 case ID_FFSCRIPT: return skip_ffscript;
21263 107 case ID_SFX: return skip_sfx;
21264 119 case ID_MIDIS: return skip_midis;
21265 119 case ID_CHEATS: return skip_cheats;
21266 107 case ID_ITEMDROPSETS: return skip_itemdropsets;
21267 107 case ID_FAVORITES: return skip_favorites;
21268 case ID_ZINFO: return skip_zinfo;
21269 }
21270
21271 return -1;
21272 2748 }
21273
21274 2748 static int maybe_skip_section(PACKFILE* f, int section_id, const byte* skip_flags)
21275 {
21276 2748 int section_enum = section_id_to_enum(section_id);
21277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2748 times.
2748 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2748 times.
2748 if (skip)
21279 {
21280 word s_version;
21281 if (!p_igetw(&s_version,f))
21282 {
21283 return qe_invalid;
21284 }
21285
21286 word c_version;
21287 if (!p_igetw(&c_version,f))
21288 {
21289 return qe_invalid;
21290 }
21291
21292 if (section_id == ID_RULES && s_version > 16)
21293 {
21294 dword dummy;
21295 if (!p_igetl(&dummy,f))
21296 {
21297 return qe_invalid;
21298 }
21299 }
21300
21301 if (section_id == ID_FFSCRIPT && s_version >= 18)
21302 {
21303 word dummy;
21304 if (!p_igetw(&dummy,f))
21305 {
21306 return qe_invalid;
21307 }
21308 }
21309
21310 dword section_length;
21311 if (!p_igetl(&section_length,f))
21312 {
21313 return qe_invalid;
21314 }
21315
21316 if (pack_fseek(f, section_length))
21317 {
21318 return qe_invalid;
21319 }
21320
21321 if (!pack_feof(f))
21322 {
21323 if (!p_mgetl(&section_id,f))
21324 {
21325 return qe_invalid;
21326 }
21327 }
21328
21329 return qe_cancel;
21330 }
21331
21332 2748 return qe_OK;
21333 2748 }
21334
21335 //Internal function for loadquest wrapper
21336 123 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, const byte *skip_flags, byte printmetadata)
21337 {
21338 123 DMapEditorLastMaptileUsed = 0;
21339 123 combosread=false;
21340 123 mapsread=false;
21341 123 fixffcs=false;
21342
21343 // show_progress=true;
21344 char tmpfilename[L_tmpnam];
21345 123 temp_name(tmpfilename);
21346 // char percent_done[30];
21347 123 bool catchup=false;
21348 byte tempbyte;
21349 123 word old_map_count=map_count;
21350
21351 123 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21352 123 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21353 123 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21354
21355
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(get_bit(skip_flags, skip_rules))
21356 {
21357 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21358 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21359 }
21360
21361 123 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21362 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21363
21364
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(get_bit(skip_flags, skip_midis))
21365 {
21366 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21367 }
21368
21369
21370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(!get_bit(skip_flags, skip_ffscript))
21371 {
21372 123 zScript.clear();
21373 123 globalmap.clear();
21374 123 genericmap.clear();
21375 123 ffcmap.clear();
21376 123 itemmap.clear();
21377 123 npcmap.clear();
21378 123 ewpnmap.clear();
21379 123 lwpnmap.clear();
21380 123 playermap.clear();
21381 123 dmapmap.clear();
21382 123 screenmap.clear();
21383 123 itemspritemap.clear();
21384 123 comboscriptmap.clear();
21385
21386
2/2
✓ Branch 0 taken 62853 times.
✓ Branch 1 taken 123 times.
62976 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21387 {
21388 62853 ffcmap[i].clear();
21389 62853 }
21390
21391 123 globalmap[0].slotname = "Slot 1:";
21392 123 globalmap[0].scriptname = "~Init";
21393 123 globalmap[0].update();
21394
21395
2/2
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 123 times.
984 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21396 {
21397 861 globalmap[i].clear();
21398 861 }
21399
21400
2/2
✓ Branch 0 taken 31365 times.
✓ Branch 1 taken 123 times.
31488 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21401 {
21402 31365 itemmap[i].clear();
21403 31365 }
21404
21405 //new script types -- prevent carrying over to a quest that you load after reading them
21406 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21407
2/2
✓ Branch 0 taken 31365 times.
✓ Branch 1 taken 123 times.
31488 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21408 {
21409 31365 npcmap[i].clear();
21410 31365 }
21411
2/2
✓ Branch 0 taken 31365 times.
✓ Branch 1 taken 123 times.
31488 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21412 {
21413 31365 lwpnmap[i].clear();
21414 31365 }
21415
2/2
✓ Branch 0 taken 31365 times.
✓ Branch 1 taken 123 times.
31488 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21416 {
21417 31365 ewpnmap[i].clear();
21418 31365 }
21419
2/2
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 123 times.
615 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21420 {
21421 492 playermap[i].clear();
21422 492 }
21423
2/2
✓ Branch 0 taken 31365 times.
✓ Branch 1 taken 123 times.
31488 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21424 {
21425 31365 dmapmap[i].clear();
21426 31365 }
21427
2/2
✓ Branch 0 taken 31365 times.
✓ Branch 1 taken 123 times.
31488 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21428 {
21429 31365 screenmap[i].clear();
21430 31365 }
21431
2/2
✓ Branch 0 taken 31365 times.
✓ Branch 1 taken 123 times.
31488 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21432 {
21433 31365 itemspritemap[i].clear();
21434 31365 }
21435
2/2
✓ Branch 0 taken 62853 times.
✓ Branch 1 taken 123 times.
62976 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21436 {
21437 62853 comboscriptmap[i].clear();
21438 62853 }
21439
2/2
✓ Branch 0 taken 62853 times.
✓ Branch 1 taken 123 times.
62976 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21440 {
21441 62853 genericmap[i].clear();
21442 62853 }
21443
21444 123 reset_scripts();
21445 123 }
21446
21447 zquestheader tempheader;
21448 123 memset(&tempheader, 0, sizeof(zquestheader));
21449 123 zinfo tempzi;
21450 123 tempzi.clear();
21451 123 load_tmp_zi = &tempzi;
21452
21453 // oldquest flag is set when an unencrypted qst file is suspected.
21454 123 bool oldquest = false;
21455 123 int32_t open_error=0;
21456 123 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21457
21458
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if (!f)
21459 {
21460 ASSERT(open_error != 0);
21461 return open_error;
21462 }
21463 char zinfofilename[2048];
21464 123 replace_extension(zinfofilename, filename, "zinfo", 2047);
21465 123 int32_t ret=0;
21466
21467 //header
21468 123 box_out("Reading Header...");
21469 123 ret=readheader(f, &tempheader, printmetadata);
21470
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
123 checkstatus(ret);
21471 123 box_out("okay.");
21472 123 box_eol();
21473
21474
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 30 times.
123 if(read_zinfo)
21475 {
21476 30 box_out("Reading ZInfo - ");
21477
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 29 times.
30 box_out(read_ext_zinfo ? "External..." : "Internal...");
21478
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 29 times.
30 if(read_ext_zinfo)
21479 {
21480 1 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21481 1 ret=readzinfo(inf, tempzi, tempheader);
21482
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(inf) pack_fclose(inf);
21483
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21484 1 }
21485 else
21486 {
21487 29 ret=readzinfo(f, tempzi, tempheader);
21488
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
29 checkstatus(ret);
21489 }
21490 30 box_out("okay.");
21491 30 box_eol();
21492 30 }
21493
21494
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
123 if(tempheader.zelda_version>=0x193)
21495 {
21496 dword section_id;
21497
21498 //section id
21499
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_mgetl(&section_id,f))
21500 {
21501 return qe_invalid;
21502 }
21503
21504 119 std::set<dword> seen_sections;
21505
21506
3/4
✓ Branch 0 taken 2867 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2748 times.
✓ Branch 3 taken 119 times.
2867 while(!pack_feof(f))
21507 {
21508
2/4
✓ Branch 0 taken 2748 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2748 times.
✗ Branch 3 not taken.
2748 if (seen_sections.contains(section_id))
21509 return qe_invalid;
21510
1/2
✓ Branch 0 taken 2748 times.
✗ Branch 1 not taken.
2748 seen_sections.insert(section_id);
21511
21512
2/4
✓ Branch 0 taken 2748 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2748 times.
✗ Branch 3 not taken.
2748 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21513 {
21514 if (retval == qe_cancel)
21515 continue;
21516 checkstatus(retval);
21517 }
21518
21519
24/25
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 119 times.
✓ Branch 3 taken 119 times.
✓ Branch 4 taken 119 times.
✓ Branch 5 taken 107 times.
✓ Branch 6 taken 119 times.
✓ Branch 7 taken 119 times.
✓ Branch 8 taken 119 times.
✓ Branch 9 taken 119 times.
✓ Branch 10 taken 119 times.
✓ Branch 11 taken 119 times.
✓ Branch 12 taken 107 times.
✓ Branch 13 taken 107 times.
✓ Branch 14 taken 119 times.
✓ Branch 15 taken 119 times.
✓ Branch 16 taken 107 times.
✓ Branch 17 taken 107 times.
✓ Branch 18 taken 107 times.
✓ Branch 19 taken 107 times.
✓ Branch 20 taken 119 times.
✓ Branch 21 taken 119 times.
✓ Branch 22 taken 107 times.
✓ Branch 23 taken 107 times.
✗ Branch 24 not taken.
2748 switch(section_id)
21520 {
21521 case ID_RULES:
21522
21523 //rules
21524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(catchup)
21525 {
21526 box_out("found.");
21527 box_eol();
21528 catchup=false;
21529 }
21530
21531
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("Reading Rules...");
21532
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 ret=readrules(f, &tempheader);
21533
1/9
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
119 checkstatus(ret);
21534
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("okay.");
21535
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_eol();
21536 119 break;
21537
21538 case ID_STRINGS:
21539
21540 //strings
21541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(catchup)
21542 {
21543 box_out("found.");
21544 box_eol();
21545 catchup=false;
21546 }
21547
21548
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("Reading Strings...");
21549
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 ret=readstrings(f, &tempheader);
21550
1/9
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
119 checkstatus(ret);
21551
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("okay.");
21552
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_eol();
21553 119 break;
21554
21555 case ID_MISC:
21556
21557 //misc data
21558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(catchup)
21559 {
21560 box_out("found.");
21561 box_eol();
21562 catchup=false;
21563 }
21564
21565
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("Reading Misc. Data...");
21566
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 ret=readmisc(f, &tempheader, Misc);
21567
1/9
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
119 checkstatus(ret);
21568
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("okay.");
21569
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_eol();
21570 119 break;
21571
21572 case ID_TILES:
21573
21574 //tiles
21575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(catchup)
21576 {
21577 box_out("found.");
21578 box_eol();
21579 catchup=false;
21580 }
21581
21582
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("Reading Tiles...");
21583
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
21584
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
119 checkstatus(ret);
21585
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("okay.");
21586
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_eol();
21587 119 break;
21588
21589 case ID_COMBOS:
21590
21591 //combos
21592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(catchup)
21593 {
21594 box_out("found.");
21595 box_eol();
21596 catchup=false;
21597 }
21598
21599
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("Reading Combos...");
21600
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
21601 119 combosread=true;
21602
1/9
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
119 checkstatus(ret);
21603
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("okay.");
21604
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_eol();
21605 119 break;
21606
21607 case ID_COMBOALIASES:
21608
21609 //combo aliases
21610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(catchup)
21611 {
21612 box_out("found.");
21613 box_eol();
21614 catchup=false;
21615 }
21616
21617
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_out("Reading Combo Aliases...");
21618
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
21619
1/9
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
107 checkstatus(ret);
21620
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_out("okay.");
21621
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_eol();
21622 107 break;
21623
21624 case ID_CSETS:
21625
21626 //color data
21627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(catchup)
21628 {
21629 box_out("found.");
21630 box_eol();
21631 catchup=false;
21632 }
21633
21634
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("Reading Color Data...");
21635
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
21636
1/9
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
119 checkstatus(ret);
21637
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("okay.");
21638
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_eol();
21639 119 break;
21640
21641 case ID_MAPS:
21642
21643 //maps
21644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(catchup)
21645 {
21646 box_out("found.");
21647 box_eol();
21648 catchup=false;
21649 }
21650
21651
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("Reading Maps...");
21652
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 ret=readmaps(f, &tempheader);
21653 119 mapsread=true;
21654
1/9
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
119 checkstatus(ret);
21655
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("okay.");
21656
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_eol();
21657 119 break;
21658
21659 case ID_DMAPS:
21660
21661 //dmaps
21662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(catchup)
21663 {
21664 box_out("found.");
21665 box_eol();
21666 catchup=false;
21667 }
21668
21669
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("Reading DMaps...");
21670
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
21671
1/9
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
119 checkstatus(ret);
21672
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("okay.");
21673
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_eol();
21674 119 break;
21675
21676 case ID_DOORS:
21677
21678 //door combo sets
21679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(catchup)
21680 {
21681 box_out("found.");
21682 box_eol();
21683 catchup=false;
21684 }
21685
21686
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("Reading Doors...");
21687
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 ret=readdoorcombosets(f, &tempheader);
21688
1/9
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
119 checkstatus(ret);
21689
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("okay.");
21690
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_eol();
21691 119 break;
21692
21693 case ID_ITEMS:
21694
21695 //items
21696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(catchup)
21697 {
21698 box_out("found.");
21699 box_eol();
21700 catchup=false;
21701 }
21702
21703
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("Reading Items...");
21704
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 ret=readitems(f, tempheader.zelda_version, tempheader.build);
21705
1/9
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
119 checkstatus(ret);
21706
21707
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("okay.");
21708
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_eol();
21709 119 break;
21710
21711 case ID_WEAPONS:
21712
21713 //weapons
21714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(catchup)
21715 {
21716 box_out("found.");
21717 box_eol();
21718 catchup=false;
21719 }
21720
21721
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("Reading Weapons...");
21722
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 ret=readweapons(f, &tempheader);
21723
1/9
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
119 checkstatus(ret);
21724
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("okay.");
21725
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_eol();
21726 119 break;
21727
21728 case ID_COLORS:
21729
21730 //misc. colors
21731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(catchup)
21732 {
21733 box_out("found.");
21734 box_eol();
21735 catchup=false;
21736 }
21737
21738
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_out("Reading Misc. Colors...");
21739
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 ret=readmisccolors(f, &tempheader, Misc);
21740
1/9
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
107 checkstatus(ret);
21741
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_out("okay.");
21742
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_eol();
21743 107 break;
21744
21745 case ID_ICONS:
21746
21747 //game icons
21748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(catchup)
21749 {
21750 box_out("found.");
21751 box_eol();
21752 catchup=false;
21753 }
21754
21755
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_out("Reading Game Icons...");
21756
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 ret=readgameicons(f, &tempheader, Misc);
21757
1/9
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
107 checkstatus(ret);
21758
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_out("okay.");
21759
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_eol();
21760 107 break;
21761
21762 case ID_INITDATA:
21763
21764 //initialization data
21765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(catchup)
21766 {
21767 box_out("found.");
21768 box_eol();
21769 catchup=false;
21770 }
21771
21772
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("Reading Init. Data...");
21773
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 ret=readinitdata(f, &tempheader);
21774
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
119 checkstatus(ret);
21775
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("okay.");
21776
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_eol();
21777
21778
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
119 if(!get_bit(skip_flags, skip_subscreens))
21779 {
21780
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 92 times.
119 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21781 {
21782
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 setupsubscreens();
21783
21784
2/2
✓ Branch 0 taken 13824 times.
✓ Branch 1 taken 27 times.
13851 for(int32_t i=0; i<MAXDMAPS; ++i)
21785 {
21786 13824 int32_t type=DMaps[i].type&dmfTYPE;
21787
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 13617 times.
13824 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21788
1/2
✓ Branch 0 taken 13824 times.
✗ Branch 1 not taken.
13824 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
21789 13824 }
21790 27 }
21791 119 }
21792
21793
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
119 if(!get_bit(skip_flags, skip_sfx))
21794 {
21795 119 setupsfx();
21796 119 }
21797
21798
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 if(!get_bit(skip_flags, skip_itemdropsets))
21799 {
21800
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 init_item_drop_sets();
21801 119 }
21802
21803
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
119 if(!get_bit(skip_flags, skip_favorites))
21804 {
21805 119 init_favorites();
21806 119 }
21807
21808 119 break;
21809
21810 case ID_GUYS:
21811
21812 //guys
21813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(catchup)
21814 {
21815 box_out("found.");
21816 box_eol();
21817 catchup=false;
21818 }
21819
21820
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("Reading Custom Guy Data...");
21821
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 ret=readguys(f, &tempheader);
21822
1/9
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
119 checkstatus(ret);
21823
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("okay.");
21824
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_eol();
21825 119 break;
21826
21827 case ID_HEROSPRITES:
21828
21829 //player sprites
21830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(catchup)
21831 {
21832 box_out("found.");
21833 box_eol();
21834 catchup=false;
21835 }
21836
21837
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_out("Reading Custom Player Sprite Data...");
21838
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 ret=readherosprites(f, &tempheader);
21839
1/9
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
107 checkstatus(ret);
21840
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_out("okay.");
21841
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_eol();
21842 107 break;
21843
21844 case ID_SUBSCREEN:
21845
21846 //custom subscreens
21847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(catchup)
21848 {
21849 box_out("found.");
21850 box_eol();
21851 catchup=false;
21852 }
21853
21854
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_out("Reading Custom Subscreen Data...");
21855
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 ret=readsubscreens(f, &tempheader);
21856
1/9
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
107 checkstatus(ret);
21857
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_out("okay.");
21858
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_eol();
21859 107 break;
21860
21861 case ID_FFSCRIPT:
21862
21863 //Freeform combo scripts
21864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(catchup)
21865 {
21866 box_out("found.");
21867 box_eol();
21868 catchup=false;
21869 }
21870
21871
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_out("Reading FF Script Data...");
21872
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 ret=readffscript(f, &tempheader);
21873
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
107 checkstatus(ret);
21874
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_out("okay.");
21875
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_eol();
21876 107 break;
21877
21878 case ID_SFX:
21879
21880 //SFX data
21881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(catchup)
21882 {
21883 box_out("found.");
21884 box_eol();
21885 catchup=false;
21886 }
21887
21888
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_out("Reading SFX Data...");
21889
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 ret=readsfx(f, &tempheader);
21890
1/9
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
107 checkstatus(ret);
21891
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_out("okay.");
21892
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_eol();
21893 107 break;
21894
21895 case ID_MIDIS:
21896
21897 //midis
21898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(catchup)
21899 {
21900 box_out("found.");
21901 box_eol();
21902 catchup=false;
21903 }
21904
21905
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("Reading Tunes...");
21906
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 ret=readtunes(f, &tempheader, tunes);
21907
1/9
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
119 checkstatus(ret);
21908
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("okay.");
21909
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_eol();
21910 119 break;
21911
21912 case ID_CHEATS:
21913
21914 //cheat codes
21915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(catchup)
21916 {
21917 box_out("found.");
21918 box_eol();
21919 catchup=false;
21920 }
21921
21922
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("Reading Cheat Codes...");
21923
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 ret=readcheatcodes(f, &tempheader);
21924
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
119 checkstatus(ret);
21925
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_out("okay.");
21926
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 box_eol();
21927 119 break;
21928
21929 case ID_ITEMDROPSETS:
21930
21931 //item drop sets
21932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(catchup)
21933 {
21934 box_out("found.");
21935 box_eol();
21936 catchup=false;
21937 }
21938
21939
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_out("Reading Item Drop Sets...");
21940
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build);
21941
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
107 checkstatus(ret);
21942
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_out("okay.");
21943
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_eol();
21944 107 break;
21945
21946 case ID_FAVORITES:
21947
21948 //favorite combos and combo aliases
21949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(catchup)
21950 {
21951 box_out("found.");
21952 box_eol();
21953 catchup=false;
21954 }
21955
21956
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_out("Reading Favorite Combos...");
21957
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 ret=readfavorites(f, tempheader.zelda_version, tempheader.build);
21958
1/9
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
107 checkstatus(ret);
21959
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_out("okay.");
21960
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 box_eol();
21961 107 break;
21962
21963 default:
21964 if(!catchup)
21965 {
21966 box_out("Bad token! Searching...");
21967 box_eol();
21968 }
21969
21970 catchup=true;
21971 break;
21972 }
21973
21974
21975
1/2
✓ Branch 0 taken 2748 times.
✗ Branch 1 not taken.
2748 if(catchup)
21976 {
21977 //section id
21978 section_id=(section_id<<8);
21979
21980 if(!p_getc(&tempbyte,f))
21981 {
21982 return qe_invalid;
21983 }
21984
21985 section_id+=tempbyte;
21986 }
21987
21988 else
21989 {
21990 //section id
21991
3/4
✓ Branch 0 taken 2748 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2629 times.
✓ Branch 3 taken 119 times.
2748 if(!pack_feof(f))
21992 {
21993
2/4
✓ Branch 0 taken 2629 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2629 times.
✗ Branch 3 not taken.
2629 if(!p_mgetl(&section_id,f))
21994 {
21995 return qe_invalid;
21996 }
21997 2629 }
21998 }
21999 }
22000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 }
22001 else
22002 {
22003
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22004
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22005
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22006
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22007
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22008
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22009
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22010
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22011
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22012
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22013
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22014
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22015
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22016
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
22017
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22018
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22019
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Custom Player Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1, 0); }},
22020
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1, 0); }},
22021 };
22022
22023
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 68 times.
140 for (auto& [desc, section_id, fn] : hardcoded_sections)
22024 {
22025 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22026 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22027 // read all the sections even if requested to skip some.
22028 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22029 // {
22030 // if (retval == qe_cancel)
22031 // continue;
22032 // checkstatus(retval);
22033 // }
22034
22035
3/6
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 68 times.
✗ Branch 5 not taken.
136 box_out(fmt::format("Reading {}...", desc).c_str());
22036
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 ret = fn();
22037
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
68 checkstatus(ret);
22038
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 box_out("okay.");
22039
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 box_eol();
22040 }
22041
22042
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!get_bit(skip_flags, skip_subscreens))
22043 {
22044
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 setupsubscreens();
22045
22046
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t i=0; i<MAXDMAPS; ++i)
22047 {
22048 2048 int32_t type=DMaps[i].type&dmfTYPE;
22049
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2036 times.
2048 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22050
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22051 2048 }
22052 4 }
22053
22054
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_out("Setting Up Default Sound Effects...");
22055
22056
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(!get_bit(skip_flags, skip_sfx))
22057 4 setupsfx();
22058
22059
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_out("okay.");
22060
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_eol();
22061
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 }
22062
22063 123 init_spritelists();
22064
22065 // check data
22066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(f)
22067 {
22068 123 pack_fclose(f);
22069 123 }
22070 123 clear_quest_tmpfile();
22071
22072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(!oldquest)
22073 {
22074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(exists(tmpfilename))
22075 {
22076 delete_file(tmpfilename);
22077 }
22078 123 }
22079
22080
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
123 if(fixffcs && combosread && mapsread)
22081 {
22082 for(int32_t i=0; i<map_count; i++)
22083 {
22084 for(int32_t j=0; j<MAPSCRS; j++)
22085 {
22086 for(int32_t m=0; m<32; m++)
22087 {
22088 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
22089 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22090 }
22091 }
22092 }
22093 }
22094
22095
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 29 times.
123 if(get_qr(qr_CONTFULL_DEP))
22096 {
22097 29 set_qr(qr_CONTFULL_DEP, 0);
22098 29 set_bit(zinit.misc, idM_CONTPERCENT, 1);
22099 29 zinit.cont_heart=100;
22100 29 zinit.start_heart=zinit.hc;
22101 29 }
22102
22103 123 box_out("Done.");
22104 123 box_eol();
22105 123 box_end(false);
22106
22107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(!get_bit(skip_flags, skip_header))
22108 {
22109 123 memcpy(Header, &tempheader, sizeof(tempheader));
22110 123 }
22111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(!get_bit(skip_flags, skip_zinfo))
22112 {
22113 123 ZI.copyFrom(tempzi);
22114 123 }
22115
22116
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(get_bit(skip_flags, skip_maps))
22117 {
22118 map_count=old_map_count;
22119 }
22120
22121
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(get_bit(skip_flags, skip_rules))
22122 {
22123 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22124 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22125 }
22126
22127
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(get_bit(skip_flags, skip_midis))
22128 {
22129 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22130 }
22131
22132 //Debug FFCore.quest_format[]
22133 123 al_trace("Quest made in ZC Version: %x\n", FFCore.quest_format[vZelda]);
22134 123 al_trace("Quest made in ZC Build: %d\n", FFCore.quest_format[vBuild]);
22135 123 al_trace("Quest Section 'Header' is Version: %d\n", FFCore.quest_format[vHeader]);
22136 123 al_trace("Quest Section 'Rules' is Version: %d\n", FFCore.quest_format[vRules]);
22137 123 al_trace("Quest Section 'Strings' is Version: %d\n", FFCore.quest_format[vStrings]);
22138 123 al_trace("Quest Section 'Misc' is Version: %d\n", FFCore.quest_format[vMisc]);
22139 123 al_trace("Quest Section 'Tiles' is Version: %d\n", FFCore.quest_format[vTiles]);
22140 123 al_trace("Quest Section 'Combos' is Version: %d\n", FFCore.quest_format[vCombos]);
22141 123 al_trace("Quest Section 'CSets' is Version: %d\n", FFCore.quest_format[vCSets]);
22142 123 al_trace("Quest Section 'Maps' is Version: %d\n", FFCore.quest_format[vMaps]);
22143 123 al_trace("Quest Section 'DMaps' is Version: %d\n", FFCore.quest_format[vDMaps]);
22144 123 al_trace("Quest Section 'Doors' is Version: %d\n", FFCore.quest_format[vDoors]);
22145 123 al_trace("Quest Section 'Items' is Version: %d\n", FFCore.quest_format[vItems]);
22146 123 al_trace("Quest Section 'Weapons' is Version: %d\n", FFCore.quest_format[vWeaponSprites]);
22147 123 al_trace("Quest Section 'Colors' is Version: %d\n", FFCore.quest_format[vColours]);
22148 123 al_trace("Quest Section 'Icons' is Version: %d\n", FFCore.quest_format[vIcons]);
22149 //al_trace("Quest Section 'Gfx Pack' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vGfxPack]);
22150 123 al_trace("Quest Section 'InitData' is Version: %d\n", FFCore.quest_format[vInitData]);
22151 123 al_trace("Quest Section 'Guys' is Version: %d\n", FFCore.quest_format[vGuys]);
22152 123 al_trace("Quest Section 'MIDIs' is Version: %d\n", FFCore.quest_format[vMIDIs]);
22153 123 al_trace("Quest Section 'Cheats' is Version: %d\n", FFCore.quest_format[vCheats]);
22154 //al_trace("Quest Section 'Save Format' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vSaveformat]);
22155 123 al_trace("Quest Section 'Combo Aliases' is Version: %d\n", FFCore.quest_format[vComboAliases]);
22156 123 al_trace("Quest Section 'Player Sprites' is Version: %d\n", FFCore.quest_format[vHeroSprites]);
22157 123 al_trace("Quest Section 'Subscreen' is Version: %d\n", FFCore.quest_format[vSubscreen]);
22158 123 al_trace("Quest Section 'Dropsets' is Version: %d\n", FFCore.quest_format[vItemDropsets]);
22159 123 al_trace("Quest Section 'FFScript' is Version: %d\n", FFCore.quest_format[vFFScript]);
22160 123 al_trace("Quest Section 'SFX' is Version: %d\n", FFCore.quest_format[vSFX]);
22161 123 al_trace("Quest Section 'Favorites' is Version: %d\n", FFCore.quest_format[vFavourites]);
22162 123 al_trace("Quest Section 'CompatRules' is Version: %d\n", FFCore.quest_format[vCompatRule]);
22163 //Print metadata for versions under 2.10 here. Bleah.
22164
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
123 if( FFCore.quest_format[vZelda] < 0x210 )
22165 {
22166 4 zprint2("\n[ZQUEST CREATOR METADATA]\n");
22167
22168
1/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
4 switch(FFCore.quest_format[vZelda])
22169 {
22170 case 0x193:
22171 {
22172 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22173 }
22174 case 0x192:
22175 {
22176 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22177 }
22178 case 0x190:
22179 {
22180 4 zprint2("Last saved in ZC Editor Version: 1.90");
22181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22182 4 else zprint2("\n");
22183 4 break;
22184 }
22185 case 0x188:
22186 {
22187 zprint2("Last saved in ZC Editor Version: 1.88");
22188 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22189 else zprint2("\n");
22190 break;
22191 }
22192 case 0x187:
22193 {
22194 zprint2("Last saved in ZC Editor Version: 1.87");
22195 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22196 else zprint2("\n");
22197 break;
22198 }
22199 case 0x186:
22200 {
22201 zprint2("Last saved in ZC Editor Version: 1.86");
22202 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22203 else zprint2("\n");
22204 break;
22205 }
22206 case 0x185:
22207 {
22208 zprint2("Last saved in ZC Editor Version: 1.85");
22209 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22210 else zprint2("\n");
22211 break;
22212 }
22213 case 0x184:
22214 {
22215 zprint2("Last saved in ZC Editor Version: 1.84");
22216 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22217 else zprint2("\n");
22218 break;
22219 }
22220 case 0x183:
22221 {
22222 zprint2("Last saved in ZC Editor Version: 1.83");
22223 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22224 else zprint2("\n");
22225 break;
22226 }
22227 case 0x182:
22228 {
22229 zprint2("Last saved in ZC Editor Version: 1.82");
22230 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22231 else zprint2("\n");
22232 break;
22233 }
22234 case 0x181:
22235 {
22236 zprint2("Last saved in ZC Editor Version: 1.81");
22237 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22238 else zprint2("\n");
22239 break;
22240 }
22241 case 0x180:
22242 {
22243 zprint2("Last saved in ZC Editor Version: 1.80");
22244 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22245 else zprint2("\n");
22246 break;
22247 }
22248 default:
22249 {
22250 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22251 }
22252 }
22253 4 }
22254
22255 123 return qe_OK;
22256
22257 invalid:
22258 box_out("error.");
22259 box_eol();
22260 box_end(true);
22261
22262 if(f)
22263 {
22264 pack_fclose(f);
22265 }
22266
22267 if(!oldquest)
22268 {
22269 if(exists(tmpfilename))
22270 {
22271 delete_file(tmpfilename);
22272 }
22273 }
22274
22275 return qe_invalid;
22276
22277 123 }
22278
22279 123 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata, bool report, byte qst_num)
22280 {
22281 123 const char* basename = get_filename(filename);
22282 123 zapp_reporting_add_breadcrumb("load_quest", basename);
22283 123 zapp_reporting_set_tag("qst.filename", basename);
22284
22285 123 loading_qst_name = filename;
22286 123 loading_qst_num = qst_num;
22287 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22288 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22289
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if (!is_ci())
22290 loadquest_report = report;
22291 123 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22292 123 load_tmp_zi = NULL;
22293 123 loading_qst_name = NULL;
22294 123 loadquest_report = false;
22295 123 loading_qst_num = 0;
22296
22297 123 zapp_reporting_set_tag("qst.title", Header->title);
22298 123 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22299
22300 123 return ret;
22301 }
22302